×
Namespaces

Variants
Actions
(Difference between revisions)

Get Display information using Qt

From Nokia Developer Wiki
Jump to: navigation, search
Yashu (Talk | contribs)
m
jimgilmour1 (Talk | contribs)
m (add open signing minor spelling)
Line 13: Line 13:
 
This code example shows how to access display information from the system. For example to get color depth and display brightness of the device. Code example use QSystemDisplayInfo API from QtMobility APIs.
 
This code example shows how to access display information from the system. For example to get color depth and display brightness of the device. Code example use QSystemDisplayInfo API from QtMobility APIs.
  
This snippet requires ReadDeviceData capabilities. Self-signing is not possible, a [[Developer certificate]] is needed to sign application for testing.
+
This snippet requires ReadDeviceData capabilities. Self-signing is not possible, a [[Developer certificate]] is needed to sign application for testing for individual phones use the [https://www.symbiansigned.com/app/page/public/openSignedOnline.do Symbian Open Online Signing] website.
  
 
==Prerequisite==
 
==Prerequisite==

Revision as of 00:03, 10 April 2010

Article Metadata
Tested with
Devices(s): Nokia 5800 and Nokia N97.
Compatibility
Platform(s): S60 3rd Edition, FP1, FP2
S60 5th Edition
Symbian
Article
Keywords: QSystemDisplayInfo, QListWidget, QScrollArea
Created: (30 Mar 2010)
Last edited: jimgilmour1 (10 Apr 2010)

Contents

Overview

This code example shows how to access display information from the system. For example to get color depth and display brightness of the device. Code example use QSystemDisplayInfo API from QtMobility APIs.

This snippet requires ReadDeviceData capabilities. Self-signing is not possible, a Developer certificate is needed to sign application for testing for individual phones use the Symbian Open Online Signing website.

Prerequisite


Headers required

#include <qsysteminfo.h>

.pro file

Modify your .pro file as follows.

QT += core \
gui \
network
INCLUDEPATH += d:/qtmobility/src/systeminfo
INCLUDEPATH += D:/QtMobility/src/global
 
CONFIG += mobility
MOBILITY = systeminfo
symbian:TARGET.CAPABILITY = ReadDeviceData


Header file

/* GetDisplayInfo.h */
 
#ifndef GETDISPLAYINFO_H
#define GETDISPLAYINFO_H
 
#include <QtGui/QMainWindow>
#include <qsysteminfo.h>
 
QTM_USE_NAMESPACE;
 
class QListWidget;
class QScrollArea;
 
class GetDisplayInfo : public QMainWindow
{
Q_OBJECT
 
public:
GetDisplayInfo(QWidget *parent = 0);
~GetDisplayInfo();
 
private:
void setWidgetGeometry(QSize* screenSize);
void getDisplayInformation();
 
private:
QSystemDisplayInfo* sysInfo;
QListWidget *listWidget;
QScrollArea *scrollArea;
};
 
#endif // GETDISPLAYINFO_H

Source file

/* GetDisplayInfo.cpp */
 
#include "GetDisplayInfo.h"
#include <QListWidget>
#include <QScrollArea>
 
GetDisplayInfo::GetDisplayInfo(QWidget *parent)
: QMainWindow(parent)
{
setWindowTitle("Get display information");
 
/*The sysInfo becomes a child of the GetDisplayInfo, and will be destroyed when the GetDisplayInfo is deleted */
sysInfo = new QSystemDisplayInfo(this);
 
/* To show items in list view */
listWidget = new QListWidget();
listWidget->setObjectName(QString::fromUtf8("listWidget"));
 
/* To make UI scrollable */
scrollArea = new QScrollArea();
setWidgetGeometry(&(size()));
 
/* scrollArea takes ownership of the listWidget, so no need to delete it */
scrollArea->setWidget(listWidget);
scrollArea->setAlignment(Qt::AlignLeft);
scrollArea->setWidgetResizable(true);
 
/* QMainWindow takes ownership of the scrollArea, so no need to delete it */
setCentralWidget(scrollArea);
getDisplayInformation();
 
}
 
GetDisplayInfo::~GetDisplayInfo()
{
}
 
void GetDisplayInfo::setWidgetGeometry(QSize* screenSize)
{
resize(*screenSize);
QRect rect(0,0,screenSize->width(), screenSize->height());
listWidget->setGeometry(rect);
}
 
void GetDisplayInfo::getDisplayInformation()
{
QString infoStr;
 
/* get color depth of screen */
infoStr.setNum(sysInfo->colorDepth(0));
infoStr.prepend("Color depth: ");
listWidget->addItem(infoStr);
 
/* get display brightness of screen */
infoStr.clear();
infoStr.setNum(sysInfo->displayBrightness(0));
infoStr.prepend("Display brightness: ");
listWidget->addItem(infoStr);
}


Postconditions

The code snippet is expected to read display information from device and show it on screen.

QtDisplayInfoSC1.jpg

Download Code Example

Related articles

77 page views in the last 30 days.
×