×
Namespaces

Variants
Actions
(Difference between revisions)

Working with QSystemInfo - System Information API - Part 1

From Nokia Developer Wiki
Jump to: navigation, search
kiran10182 (Talk | contribs)
(Created page with 'Category:DraftCategory:Qt for Symbian {{UnderConstruction}} {{Tip| Read this article before moving forward: Setting up environment for Qt Mobility API}} == Overview…')
 
hamishwillee (Talk | contribs)
m (Text replace - "<code cpp>" to "<code cpp-qt>")
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Draft]][[Category:Qt for Symbian]]
+
{{ArticleMetaData <!-- v1.2 -->
{{UnderConstruction}}
+
|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]]
 +
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
|'''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
 +
|-
 +
|}
  
{{Tip| Read this article before moving forward: [[Setting up environment for Qt Mobility API]]}}
 
  
== Overview ==  
+
 
 +
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"
 +
|-
 +
|'''Keywords (APIs, classes, methods, functions)''': QSystemInfo, QString, QStringList, QButton
 +
|}
 +
 
 +
 
 +
{{Tip|<b></b>
 +
* 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]]
 +
}}
 +
 
 +
 
 +
= Overview =  
 
This is a part 1 of the '''''QSystemInfo API''''' which is a part of the '''''System Information API''''' from '''''Qt Mobility project'''''.
 
This is a part 1 of the '''''QSystemInfo API''''' which is a part of the '''''System Information API''''' from '''''Qt Mobility project'''''.
  
== What is covered in QSystemInfo API Part 1 ==
+
= What is covered in QSystemInfo API Part 1 =
 
* It is a part of the System Information API.
 
* It is a part of the System Information API.
 
* This article covers information about
 
* This article covers information about
Line 15: Line 61:
  
  
== Capabilities required ==
+
= Capabilities required =
 
* None
 
* None
  
  
== UI design (.ui file) ==
+
= UI design (.ui file) =
 
[[File:QSystemInfo-UI Part1.png]]
 
[[File:QSystemInfo-UI Part1.png]]
  
  
  
== 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 32: 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 38: Line 84:
  
  
== Implementing QSystemInfo API ==
+
= Implementing QSystemInfo API =
* QSystemInfo API is a part of the QtMobility namespace. So declare the QtMobiliyt 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 64: Line 110:
  
 
public slots:
 
public slots:
void DisplayCurrentCountryCode();
+
void displayCurrentCountryCode();
void DisplayCurrentLanguage();
+
void displayCurrentLanguage();
void DisplayAvailableCountryCodes();
+
void displayAvailableCountryCodes();
void ResetAllFields();
+
void resetAllFields();
  
 
private:
 
private:
Line 78: Line 124:
  
  
=== Source file ===
+
== Source file ==
<code cpp>
+
<code cpp-qt>
 
#include "SystemInformation.h"
 
#include "SystemInformation.h"
  
Line 91: Line 137:
 
SIGNAL(clicked()),
 
SIGNAL(clicked()),
 
this,  
 
this,  
SLOT(DisplayCurrentLanguage()));
+
SLOT(displayCurrentLanguage()));
 
QObject::connect(ui.countryCodeButton,  
 
QObject::connect(ui.countryCodeButton,  
 
SIGNAL(clicked()),
 
SIGNAL(clicked()),
 
this,  
 
this,  
SLOT(DisplayCurrentCountryCode()));
+
SLOT(displayCurrentCountryCode()));
 
QObject::connect(ui.availableLanguagesButton,  
 
QObject::connect(ui.availableLanguagesButton,  
 
SIGNAL(clicked()),
 
SIGNAL(clicked()),
 
this,  
 
this,  
SLOT(DisplayAvailableCountryCodes()));
+
SLOT(displayAvailableCountryCodes()));
 
QObject::connect(ui.resetButton,  
 
QObject::connect(ui.resetButton,  
 
SIGNAL(clicked()),
 
SIGNAL(clicked()),
 
this,  
 
this,  
SLOT(ResetAllFields()));
+
SLOT(resetAllFields()));
 
}
 
}
  
Line 112: Line 158:
 
}
 
}
  
void SystemInformation::DisplayCurrentCountryCode()
+
void SystemInformation::displayCurrentCountryCode()
 
{
 
{
 
if(sysInfo)
 
if(sysInfo)
Line 121: Line 167:
 
}
 
}
  
void SystemInformation::DisplayCurrentLanguage()
+
void SystemInformation::displayCurrentLanguage()
 
{
 
{
 
if(sysInfo)
 
if(sysInfo)
Line 130: Line 176:
 
}
 
}
  
void SystemInformation::DisplayAvailableCountryCodes()
+
void SystemInformation::displayAvailableCountryCodes()
 
{
 
{
 
if(sysInfo)
 
if(sysInfo)
Line 139: Line 185:
 
}
 
}
  
void SystemInformation::ResetAllFields()
+
void SystemInformation::resetAllFields()
 
{
 
{
 
if(sysInfo)
 
if(sysInfo)
Line 151: Line 197:
  
  
== Output ==
+
= Output =
 
[[File:QSystemInfo-part1.jpg]]
 
[[File:QSystemInfo-part1.jpg]]
  
  
 +
= Useful functions =
 +
* QStringList availableLanguages();
 +
* QString currentCountryCode();
 +
* QString currentLanguage();
  
== Useful functions ==
+
= Keywords =
  
 
+
==Headers==
 
+
== Keywords ==
+
 
+
 
+
===Headers===
+
 
* #include <qsysteminfo.h>
 
* #include <qsysteminfo.h>
  
 
+
==Classes==
===Classes===
+
 
* QSystemInfo
 
* QSystemInfo
 +
* QString
 +
* QStringList
 +
* QButton
  
 
+
= Example Application =
== Example Application ==
+
 
* A working example application is available to download from here: [[Media:SystemInformation part1.zip|QSystemInfo part1.zip]]
 
* A working example application is available to download from here: [[Media:SystemInformation part1.zip|QSystemInfo part1.zip]]
  
  
== 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 QSystemInfo - System Information API - Part 2]]
 
* [[Working with QSystemInfo - System Information API - Part 2]]
 
* [[Working with QSystemDeviceInfo - System Information API - Part 1]]
 
* [[Working with QSystemDeviceInfo - System Information API - Part 1]]
 +
* [[Working with QSystemStorageInfo - System Information API]]
 +
* [[Working with QSystemDisplayInfo - System Information API]]
 +
* [[Working with QSystemNetworkInfo - System Information API - Part 1]]
 +
* [[Working with QSystemNetworkInfo - System Information API - Part 2]]
  
 
+
= Reference links=
 
+
== Reference links==
+
 
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
 
* [http://qt.nokia.com/ Qt - cross-platform application and UI framework]
* [http://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
+
* [http://developer.qt.nokia.com/wiki/Category:Qt_Labs_Projects Qt Mobility API]
* [http://qt.nokia.com/developer/new-qt-apis New Qt APIs Beta - Mobility Project]
+
* [http://qt.nokia.com/developer/qt-roadmap New Qt APIs Beta - Mobility Project]
* SDK help
+
* 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.
118 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.

×