×
Namespaces

Variants
Actions
(Difference between revisions)

Working with QSystemInfo - System Information API - Part 2

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>")
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
 +
{{ArticleMetaData <!-- v1.2 -->
 +
|sourcecode= [[Media:SystemFeatureInfo.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/ Qt SDK 1.1.4]) -->
 +
|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 -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|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= 20100308
 +
|author= [[User:Kiran10182]]
 +
}}
 
[[Category:Qt Mobility]]
 
[[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"  
Line 9: Line 31:
 
|'''Tested on devices''' || Nokia 5800 xPressMusic
 
|'''Tested on devices''' || Nokia 5800 xPressMusic
 
|-
 
|-
|'''Category''' || Qt for Symbian
+
|'''Category''' || Qt
 
|'''Subcategory''' || Qt Mobility API
 
|'''Subcategory''' || Qt Mobility API
 
|-
 
|-
Line 23: Line 45:
  
 
{{Tip|<b></b>
 
{{Tip|<b></b>
* Please read this article before moving forward: [[Setting up environment for Qt Mobility API]]
+
* Please read this article before moving forward: [[Archived: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]]
 
* Setup Carbide.c++ IDE as explained in this article: [[Working with Carbide.c++ IDE for Qt Mobility APIs]]
 
}}
 
}}
Line 51: Line 73:
 
= 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 57: Line 79:
  
 
* Add Qt-specific configuration options in .pro file as shown below
 
* Add Qt-specific configuration options in .pro file as shown below
<code cpp>
+
<code cpp-qt>
 
QT += network
 
QT += network
 
</code>
 
</code>
  
 
* Add required capability in .pro file as shown below:
 
* Add required capability in .pro file as shown below:
<code cpp>
+
<code cpp-qt>
 
symbian:TARGET.CAPABILITY = ReadDeviceData
 
symbian:TARGET.CAPABILITY = ReadDeviceData
 
</code>
 
</code>
Line 69: Line 91:
 
= Implementing QSystemInfo API =
 
= Implementing QSystemInfo API =
 
* QSystemInfo API is a part of the QtMobility namespace. So declare the QtMobility namespace as shown below:
 
* QSystemInfo 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 SYSTEMFEATUREINFO_H
 
#ifndef SYSTEMFEATUREINFO_H
 
#define SYSTEMFEATUREINFO_H
 
#define SYSTEMFEATUREINFO_H
Line 106: Line 128:
  
 
== Source file ==
 
== Source file ==
<code cpp>
+
<code cpp-qt>
 
#include "SystemFeatureInfo.h"
 
#include "SystemFeatureInfo.h"
  
Line 203: Line 225:
 
= Related articles =  
 
= Related articles =  
 
* [[Getting started with Qt Mobility APIs]]
 
* [[Getting started with Qt Mobility APIs]]
* [[Setting up environment for Qt Mobility API]]
+
* [[Archived:Setting up environment for Qt Mobility API]]
 
* [[Working with Carbide.c++ IDE for Qt Mobility APIs]]
 
* [[Working with Carbide.c++ IDE for Qt Mobility APIs]]
 
* [[Working with QSystemInfo - System Information API - Part 1]]
 
* [[Working with QSystemInfo - System Information API - Part 1]]

Latest revision as of 04:23, 11 October 2012

Article Metadata
Code ExampleCompatibility
Platform(s):
Symbian
Article
Created: kiran10182 (08 Mar 2010)
Last edited: hamishwillee (11 Oct 2012)
ID Creation date 8-March-2010
Platform S60 3rd Edition, FP1, FP2

S60 5th Edition

Tested on devices Nokia 5800 xPressMusic
Category Qt Subcategory Qt Mobility API


Keywords (APIs, classes, methods, functions): QSystemInfo, QString, QStringList, QButton, QLabel, QComboBox,


Tip.pngTip: 


Contents

[edit] Overview

This is a part 2 of the QSystemInfo API which is a part of the System Information API from Qt Mobility project.


[edit] What is covered in QSystemInfo API Part 2

  • It is a part of the System Information API.
  • This article covers information about
    • Available features of the device
    • Version information of the OS
    • Current firmware information of the device


[edit] Capabilities required

  • ReadDeviceData


[edit] UI design (.ui file)

SystemFeatureInfo 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
  • Add Qt-specific configuration options in .pro file as shown below
QT += network
  • Add required capability in .pro file as shown below:
symbian:TARGET.CAPABILITY = ReadDeviceData


[edit] Implementing QSystemInfo API

  • QSystemInfo API is a part of the QtMobility namespace. So declare the QtMobility namespace as shown below:
using namespace QtMobility;

[edit] Header file

#ifndef SYSTEMFEATUREINFO_H
#define SYSTEMFEATUREINFO_H
 
#include <QtGui/QWidget>
#include "ui_SystemFeatureInfo.h"
#include <qsysteminfo.h>
 
using namespace QtMobility;
class SystemFeatureInfo : public QWidget
{
Q_OBJECT
 
public:
SystemFeatureInfo(QWidget *parent = 0);
~SystemFeatureInfo();
 
public slots:
void checkFeatureAvailability(int aIndex);
void listFirmwareInformation();
void resetAllFields();
 
private:
Ui::SystemFeatureInfo ui;
QSystemInfo* sysInfo;
};
 
#endif // SYSTEMFEATUREINFO_H


[edit] Source file

#include "SystemFeatureInfo.h"
 
SystemFeatureInfo::SystemFeatureInfo(QWidget *parent)
: QWidget(parent), sysInfo(NULL)
{
ui.setupUi(this);
sysInfo = new QSystemInfo();
 
QObject::connect(ui.featureComboBox,
SIGNAL(currentIndexChanged(int)),
this,
SLOT(checkFeatureAvailability(int)));
QObject::connect(ui.listVersionInfoButton,
SIGNAL(clicked()),
this,
SLOT(listFirmwareInformation()));
QObject::connect(ui.resetButton,
SIGNAL(clicked()),
this,
SLOT(resetAllFields()));
}
 
SystemFeatureInfo::~SystemFeatureInfo()
{
delete sysInfo;
sysInfo = NULL;
}
 
void SystemFeatureInfo::checkFeatureAvailability(int aIndex)
{
ASSERT(aIndex >=0 && aIndex <=13);
 
if(! aIndex)
{
ui.label->clear();
return;
}
 
bool val = sysInfo->hasFeatureSupported((QSystemInfo::Feature)(aIndex-1));
if(val)
{
ui.label->setText("Available");
}
else
{
ui.label->setText("Not available");
}
}
 
void SystemFeatureInfo::listFirmwareInformation()
{
if(sysInfo)
{
QString os = sysInfo->version(QSystemInfo::Os);
ui.OSlabel->setText(sysInfo->version(QSystemInfo::Os));
ui.qtLabel->setText(sysInfo->version(QSystemInfo::QtCore));
ui.firmwareLabel->setText(sysInfo->version(QSystemInfo::Firmware));
}
}
void SystemFeatureInfo::resetAllFields()
{
ui.featureComboBox->setCurrentIndex(0);
ui.label->clear();
ui.OSlabel->clear();
ui.qtLabel->clear();
ui.firmwareLabel->clear();
}


[edit] Output

SystemFeatureInfo device.jpg


[edit] Useful functions

  • bool hasFeatureSupported(QSystemInfo::Feature feature);
  • QString version(QSystemInfo::Version type, const QString & parameter = QString());

[edit] Keywords

[edit] Headers

  • #include <qsysteminfo.h>

[edit] Classes

  • QSystemInfo
  • QString
  • QStringList
  • QButton
  • QLabel
  • QComboBox

[edit] Example Application


[edit] Related articles

[edit] Reference links

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

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×