×
Namespaces

Variants
Actions
(Difference between revisions)

Working with QSystemInfo - System Information API - Part 1

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Bot fixing redirect link)
hamishwillee (Talk | contribs)
m (Text replace - "<code cpp>" to "<code cpp-qt>")
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
 +
{{ArticleMetaData <!-- v1.2 -->
 +
|sourcecode= [[Media:SystemInformation part1.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 50: Line 72:
 
= 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 56: Line 78:
  
 
* 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>
Line 64: Line 86:
 
= 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 SYSTEMINFORMATION_H
 
#ifndef SYSTEMINFORMATION_H
 
#define SYSTEMINFORMATION_H
 
#define SYSTEMINFORMATION_H
Line 103: Line 125:
  
 
== Source file ==
 
== Source file ==
<code cpp>
+
<code cpp-qt>
 
#include "SystemInformation.h"
 
#include "SystemInformation.h"
  
Line 201: Line 223:
 
= 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 2]]
 
* [[Working with QSystemInfo - System Information API - Part 2]]
Line 214: Line 236:
 
* [http://developer.qt.nokia.com/wiki/Category:Qt_Labs_Projects Qt Mobility API]
 
* [http://developer.qt.nokia.com/wiki/Category:Qt_Labs_Projects 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[[Category:Code Examples]]
+
* SDK help[[Category:Code Examples]][[Category:MeeGo Harmattan]] [[Category:Symbian]]

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


Tip.pngTip: 


Contents

[edit] Overview

This is a part 1 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 1

  • It is a part of the System Information API.
  • This article covers information about
    • Available languages in the device
    • Current language of the device
    • Current country code of the device


[edit] Capabilities required

  • None


[edit] UI design (.ui file)

QSystemInfo-UI Part1.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


[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 SYSTEMINFORMATION_H
#define SYSTEMINFORMATION_H
 
#include <QtGui/QWidget>
#include "ui_SystemInformation.h"
#include <qsysteminfo.h>
 
using namespace QtMobility;
 
class SystemInformation : public QWidget
{
Q_OBJECT
 
public:
SystemInformation(QWidget *parent = 0);
~SystemInformation();
 
public slots:
void displayCurrentCountryCode();
void displayCurrentLanguage();
void displayAvailableCountryCodes();
void resetAllFields();
 
private:
Ui::SystemInformation ui;
QSystemInfo* sysInfo;
};
 
#endif // SYSTEMINFORMATION_H


[edit] Source file

#include "SystemInformation.h"
 
SystemInformation::SystemInformation(QWidget *parent)
: QWidget(parent), sysInfo(NULL)
{
ui.setupUi(this);
sysInfo = new QSystemInfo();
 
QObject::connect(ui.curLanguageButton,
SIGNAL(clicked()),
this,
SLOT(displayCurrentLanguage()));
QObject::connect(ui.countryCodeButton,
SIGNAL(clicked()),
this,
SLOT(displayCurrentCountryCode()));
QObject::connect(ui.availableLanguagesButton,
SIGNAL(clicked()),
this,
SLOT(displayAvailableCountryCodes()));
QObject::connect(ui.resetButton,
SIGNAL(clicked()),
this,
SLOT(resetAllFields()));
}
 
SystemInformation::~SystemInformation()
{
delete sysInfo;
sysInfo = NULL;
}
 
void SystemInformation::displayCurrentCountryCode()
{
if(sysInfo)
{
QString str = sysInfo->currentCountryCode();
ui.countryCodeLabel->setText(str);
}
}
 
void SystemInformation::displayCurrentLanguage()
{
if(sysInfo)
{
QString str = sysInfo->currentLanguage();
ui.languageLabel->setText(str);
}
}
 
void SystemInformation::displayAvailableCountryCodes()
{
if(sysInfo)
{
QStringList list = sysInfo->availableLanguages();
ui.languageComboBox->addItems(list);
}
}
 
void SystemInformation::resetAllFields()
{
if(sysInfo)
{
ui.languageLabel->clear();
ui.countryCodeLabel->clear();
ui.languageComboBox->clear();
}
}


[edit] Output

QSystemInfo-part1.jpg


[edit] Useful functions

  • QStringList availableLanguages();
  • QString currentCountryCode();
  • QString currentLanguage();

[edit] Keywords

[edit] Headers

  • #include <qsysteminfo.h>

[edit] Classes

  • QSystemInfo
  • QString
  • QStringList
  • QButton

[edit] Example Application


[edit] Related articles

[edit] Reference links

This page was last modified on 11 October 2012, at 04:23.
108 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.

×