Namespaces
Variants
Actions
(Difference between revisions)

Working with QSystemDisplayInfo - System Information API

Jump to: navigation, search
m (Hamishwillee - Update ArticleMetaData. Subedit)
m (Hamishwillee - Addition to article of: Category:MeeGo Category:Symbian. (Add platform categories))
Line 155: Line 155:
 
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
 
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
 
* [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project]
 
* [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project]
* SDK help
+
* SDK help[[Category:MeeGo]] [[Category:Symbian]]

Revision as of 08:50, 15 February 2012

Article Metadata

Code Example
Tested with
Devices(s): Nokia 5800 xPressMusic

Compatibility
Platform(s): S60 3rd Edition, FP1, FP2
S60 5th Edition

Platform Security
Signing Required: Self-Signed
Capabilities: None

Article
Keywords: QSystemDisplayInfo, QString, QButton, QLabel
Created: kiran10182 (10 Mar 2010)
Last edited: hamishwillee (15 Feb 2012)

Contents

Overview

This article shows how to use the Qt Mobility System Information API: QSystemDisplayInfo.

What is covered in QSystemDisplayInfo 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.

UI design (.ui file)

QSystemDisplayInfo UI.PNG

Project configuration file (.Pro file)

Add the Qt Mobility project configuration option in the .Pro file as shown below

CONFIG += mobility
MOBILITY += systeminfo

Note, no capabilities are required

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

QSystemDisplayInfo device.jpg


Useful functions

  • int colorDepth ( int screenNumber );
  • int displayBrightness ( int screen );

Headers

  • #include <qsysteminfo.h>

Classes

  • QSystemDisplayInfo
  • QString
  • QButton
  • QLabel

Example Application

Related articles

Reference links

86 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved