×
Namespaces

Variants
Actions
(Difference between revisions)

Working with QSystemDisplayInfo - System Information API

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Text replace - "Category:MeeGo" to "Category:MeeGo Harmattan")
hamishwillee (Talk | contribs)
m (Text replace - "<code cpp>" to "<code cpp-qt>")
 
Line 34: Line 34:
 
== Project configuration file (.Pro file) ==
 
== Project configuration file (.Pro file) ==
 
Add the Qt Mobility project configuration option in the .Pro file as shown below
 
Add the Qt Mobility project configuration option in the .Pro file as shown below
<code cpp>
+
<code cpp-qt>
 
CONFIG += mobility
 
CONFIG += mobility
 
MOBILITY += systeminfo
 
MOBILITY += systeminfo
Line 42: Line 42:
 
== Implementing QSystemDisplayInfo API ==
 
== Implementing QSystemDisplayInfo API ==
 
QSystemDisplayInfo API is a part of the QtMobility namespace. So declare the QtMobility namespace as shown below:
 
QSystemDisplayInfo API is a part of the QtMobility namespace. So declare the QtMobility namespace as shown below:
<code cpp>
+
<code cpp-qt>
 
using namespace QtMobility;
 
using namespace QtMobility;
 
</code>
 
</code>
  
 
=== Header file===
 
=== Header file===
<code cpp>
+
<code cpp-qt>
 
#ifndef SYSTEMDISPLAYINFO_H
 
#ifndef SYSTEMDISPLAYINFO_H
 
#define SYSTEMDISPLAYINFO_H
 
#define SYSTEMDISPLAYINFO_H
Line 78: Line 78:
  
 
=== Source file ===
 
=== Source file ===
<code cpp>
+
<code cpp-qt>
 
#include "SystemDisplayInfo.h"
 
#include "SystemDisplayInfo.h"
  

Latest revision as of 04:23, 11 October 2012

Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 xPressMusic
Compatibility
Platform(s): S60 3rd Edition, FP1, FP2
S60 5th Edition
Symbian
Platform Security
Signing Required: Self-Signed
Capabilities: None
Article
Keywords: QSystemDisplayInfo, QString, QButton, QLabel
Created: kiran10182 (10 Mar 2010)
Last edited: hamishwillee (11 Oct 2012)

Contents

[edit] Overview

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

[edit] 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.

[edit] UI design (.ui file)

QSystemDisplayInfo UI.PNG

[edit] 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

[edit] Implementing QSystemDisplayInfo API

QSystemDisplayInfo API is a part of the QtMobility namespace. So declare the QtMobility namespace as shown below:

using namespace QtMobility;

[edit] 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


[edit] 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();
}

[edit] Output

QSystemDisplayInfo device.jpg


[edit] Useful functions

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

[edit] Headers

  • #include <qsysteminfo.h>

[edit] Classes

  • QSystemDisplayInfo
  • QString
  • QButton
  • QLabel

[edit] Example Application

[edit] Related articles

[edit] Reference links

This page was last modified on 11 October 2012, at 04:23.
70 page views in the last 30 days.
×