Working with QSystemDisplayInfo - System Information API
hamishwillee
(Talk | contribs) m (Bot fixing redirect link) |
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot addition of Template:ArticleMetaData) |
||
| Line 1: | Line 1: | ||
| − | [[Category:Qt Mobility]] | + | {{ArticleMetaData |
| + | |sourcecode=[[Media:SystemDisplayInfo.zip]] | ||
| + | |installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) --> | ||
| + | |devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') --> | ||
| + | |sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> | ||
| + | |platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later --> | ||
| + | |devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | ||
| + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> | ||
| + | |signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> | ||
| + | |capabilities=<!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | ||
| + | |keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase --> | ||
| + | |id= <!-- Article Id (Knowledge base articles only) --> | ||
| + | |language=<!-- Language category code for non-English topics - e.g. Lang-Chinese --> | ||
| + | |review-by=<!-- After re-review: [[User:username]] --> | ||
| + | |review-timestamp=<!-- After re-review: YYYYMMDD --> | ||
| + | |update-by=<!-- After significant update: [[User:username]]--> | ||
| + | |update-timestamp=<!-- After significant update: YYYYMMDD --> | ||
| + | |creationdate=20100310 | ||
| + | |author=[[User:Kiran10182]] | ||
| + | }}[[Category:Qt Mobility]] | ||
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0" | {|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0" | ||
|- | |- | ||
Revision as of 08:21, 21 October 2011
Article Metadata
Code Example
Source file: Media:SystemDisplayInfo.zip
Article
Created: kiran10182
(10 Mar 2010)
Last edited: hamishwillee
(21 Oct 2011)
| ID | Creation date | 9-March-2010 | |
| Platform | S60 3rd Edition, FP1, FP2
S60 5th Edition |
Tested on devices | Nokia 5800 xPressMusic |
| Category | Qt for Symbian | Subcategory | Qt Mobility API |
| Keywords (APIs, classes, methods, functions): QSystemDisplayInfo, QString, QButton, QLabel |
Tip:
- Please read this article before moving forward: Setting up environment for Qt Mobility API
- Setup Carbide.c++ IDE as explained in this article: Working with Carbide.c++ IDE for Qt Mobility APIs
Contents |
Overview
This article shows how to use QSystemDisplayInfo API which is a part of the System Information API from Qt Mobility project.
What is covered in QSystemDisplayInfo API
- It is a part of the System Information API.
- This article covers information about
- Color depth value of a screen number in bits per pixel
- Display brightness of screen in % between 1 - 100 scale.
Capabilities required
- None
UI design (.ui file)
Project configuration file (.Pro file)
- Add the Qt Mobility project configuration option in the .Pro file as shown below
CONFIG += mobility
MOBILITY += systeminfo
Implementing QSystemDisplayInfo API
- QSystemDisplayInfo API is a part of the QtMobility namespace. So declare the QtMobility namespace as shown below:
using namespace QtMobility;
Header file
#ifndef SYSTEMDISPLAYINFO_H
#define SYSTEMDISPLAYINFO_H
#include <QtGui/QWidget>
#include "ui_SystemDisplayInfo.h"
#include <qsysteminfo.h>
using namespace QtMobility;
class SystemDisplayInfo : public QWidget
{
Q_OBJECT
public:
SystemDisplayInfo(QWidget *parent = 0);
~SystemDisplayInfo();
public slots:
void listDisplayInformation();
void resetAllFields();
private:
Ui::SystemDisplayInfo ui;
QSystemDisplayInfo* displayInfo;
};
#endif // SYSTEMDISPLAYINFO_H
Source file
#include "SystemDisplayInfo.h"
SystemDisplayInfo::SystemDisplayInfo(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
displayInfo = new QSystemDisplayInfo();
QObject::connect(ui.listDisplayInfoButton,
SIGNAL(clicked()),
this,
SLOT(listDisplayInformation()));
QObject::connect(ui.resetButton,
SIGNAL(clicked()),
this,
SLOT(resetAllFields()));
}
SystemDisplayInfo::~SystemDisplayInfo()
{
delete displayInfo;
displayInfo = NULL;
}
void SystemDisplayInfo::listDisplayInformation()
{
QString colorDepthStr = QString::number(displayInfo->colorDepth(0));
ui.colorDepthLabel->setText(colorDepthStr);
QString brightnessStr = QString::number(displayInfo->displayBrightness(0));
ui.brightnessLabel->setText(brightnessStr);
}
void SystemDisplayInfo::resetAllFields()
{
ui.colorDepthLabel->clear();
ui.brightnessLabel->clear();
}
Output
Useful functions
- int colorDepth ( int screenNumber );
- int displayBrightness ( int screen );
Keywords
Headers
- #include <qsysteminfo.h>
Classes
- QSystemDisplayInfo
- QString
- QButton
- QLabel
Example Application
- A working example application is available to download from here: QSystemDisplayInfo.zip
Related articles
- Getting started with Qt Mobility APIs
- Setting up environment for Qt Mobility API
- Working with Carbide.c++ IDE for Qt Mobility APIs
- Working with QSystemInfo - System Information API - Part 1
- Working with QSystemInfo - System Information API - Part 2
- Working with QSystemDeviceInfo - System Information API - Part 1
- Working with QSystemStorageInfo - System Information API
- Working with QSystemNetworkInfo - System Information API - Part 1
- Working with QSystemNetworkInfo - System Information API - Part 2


