×
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
kiran10182 (Talk | contribs)
m
Line 23: Line 23:
  
 
{{Tip|<b></b>
 
{{Tip|<b></b>
* Read this article before moving forward: [[Setting up environment for Qt Mobility API]]
+
* Please read this article before moving forward: [[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]]
 
}}
 
}}
 +
  
 
= Overview =  
 
= Overview =  
Line 87: Line 88:
  
 
public slots:
 
public slots:
void DisplayCurrentCountryCode();
+
void displayCurrentCountryCode();
void DisplayCurrentLanguage();
+
void displayCurrentLanguage();
void DisplayAvailableCountryCodes();
+
void displayAvailableCountryCodes();
void ResetAllFields();
+
void resetAllFields();
  
 
private:
 
private:
Line 114: Line 115:
 
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 135: Line 136:
 
}
 
}
  
void SystemInformation::DisplayCurrentCountryCode()
+
void SystemInformation::displayCurrentCountryCode()
 
{
 
{
 
if(sysInfo)
 
if(sysInfo)
Line 144: Line 145:
 
}
 
}
  
void SystemInformation::DisplayCurrentLanguage()
+
void SystemInformation::displayCurrentLanguage()
 
{
 
{
 
if(sysInfo)
 
if(sysInfo)
Line 153: Line 154:
 
}
 
}
  
void SystemInformation::DisplayAvailableCountryCodes()
+
void SystemInformation::displayAvailableCountryCodes()
 
{
 
{
 
if(sysInfo)
 
if(sysInfo)
Line 162: Line 163:
 
}
 
}
  
void SystemInformation::ResetAllFields()
+
void SystemInformation::resetAllFields()
 
{
 
{
 
if(sysInfo)
 
if(sysInfo)
Line 172: Line 173:
 
}
 
}
 
</code>
 
</code>
 +
  
 
= Output =
 
= Output =
 
[[File:QSystemInfo-part1.jpg]]
 
[[File:QSystemInfo-part1.jpg]]
 
  
  
Line 181: Line 182:
  
  
 +
= Keywords =
  
 
==Headers==
 
==Headers==
 
* #include <qsysteminfo.h>
 
* #include <qsysteminfo.h>
 
  
 
==Classes==
 
==Classes==
 
* QSystemInfo
 
* QSystemInfo
 
+
* QString
 +
* QStringList
 +
* QButton
  
 
= Example Application =
 
= Example Application =

Revision as of 21:34, 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

Keywords

Headers

  • #include <qsysteminfo.h>

Classes

  • QSystemInfo
  • QString
  • QStringList
  • QButton

Example Application


Related articles

Reference links

67 page views in the last 30 days.
×