×
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 (Hamishwillee - Bot update - Add ArticleMetaData)
hamishwillee (Talk | contribs)
m (Text replace - "<code cpp>" to "<code cpp-qt>")
 
Line 72: 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 78: 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 86: 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 125: Line 125:
  
 
== Source file ==
 
== Source file ==
<code cpp>
+
<code cpp-qt>
 
#include "SystemInformation.h"
 
#include "SystemInformation.h"
  

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.
103 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.

×