×
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)
m (Related articles)
kiran10182 (Talk | contribs)
m
Line 1: Line 1:
[[Category:Qt for Symbian]][[Category:Code Examples]]
+
[[Category:Qt]][[Category:Qt for Symbian]][[Category:Code Examples]]
 
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"  
 
{|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0"  
 
|-
 
|-
Line 21: Line 21:
 
|}
 
|}
  
 
{{UnderConstruction}}
 
  
 
{{Tip|<b></b>
 
{{Tip|<b></b>
Line 29: Line 27:
 
}}
 
}}
  
== Overview ==  
+
= 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 40: Line 38:
  
  
== 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>
Line 63: Line 61:
  
  
== 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>
Line 69: Line 67:
 
</code>
 
</code>
  
=== Header file===
+
== Header file==
 
<code cpp>
 
<code cpp>
 
#ifndef SYSTEMINFORMATION_H
 
#ifndef SYSTEMINFORMATION_H
Line 103: Line 101:
  
  
=== Source file ===
+
== Source file ==
 
<code cpp>
 
<code cpp>
 
#include "SystemInformation.h"
 
#include "SystemInformation.h"
Line 175: Line 173:
 
</code>
 
</code>
  
== Output ==
+
= Output =
 
[[File:QSystemInfo-part1.jpg]]
 
[[File:QSystemInfo-part1.jpg]]
  
  
  
== Useful functions ==
+
= Useful functions =
 
+
 
+
  
== Keywords ==
 
  
  
===Headers===
+
==Headers==
 
* #include <qsysteminfo.h>
 
* #include <qsysteminfo.h>
  
  
===Classes===
+
==Classes==
 
* QSystemInfo
 
* QSystemInfo
  
  
== 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]]
 
* [[Setting up environment for Qt Mobility API]]
Line 210: Line 205:
 
* [[Working with QSystemNetworkInfo - System Information API - Part 2]]
 
* [[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://labs.trolltech.com/page/Projects/QtMobility Qt Mobility API]
 
* [http://qt.nokia.com/developer/new-qt-apis New Qt APIs Beta - Mobility Project]
 
* [http://qt.nokia.com/developer/new-qt-apis New Qt APIs Beta - Mobility Project]
 
* SDK help
 
* SDK help

Revision as of 21:00, 31 March 2010

ID Creation date 8-March-2010
Platform S60 3rd Edition, FP1, FP2

S60 5th Edition

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


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


Tip.pngTip: 

Contents

Overview

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

  • 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


Capabilities required

  • None


UI design (.ui file)

QSystemInfo-UI Part1.png


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


Implementing QSystemInfo API

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

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


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

Output

QSystemInfo-part1.jpg


Useful functions

Headers

  • #include <qsysteminfo.h>


Classes

  • QSystemInfo


Example Application


Related articles

Reference links

133 page views in the last 30 days.
×