Working with QSystemDeviceInfo - System Information API - Part 1
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…') |
kiran10182
(Talk | contribs) |
||
| Line 1: | Line 1: | ||
| − | [[Category:Draft]][[Category:Qt for Symbian]] | + | [[Category:Draft]][[Category:Qt for Symbian]][[Category:Code Examples]] |
| + | {|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 for Symbian | ||
| + | |'''Subcategory''' || Qt Mobility API | ||
| + | |- | ||
| + | |} | ||
| + | |||
| + | |||
| + | |||
| + | {|style="background:#eceff2" width="660px" border="1" cellpadding="5" cellspacing="0" | ||
| + | |- | ||
| + | |'''Keywords (APIs, classes, methods, functions)''': QSystemDeviceInfo, QString, QStringList, QButton, QLabel | ||
| + | |} | ||
| + | |||
| + | |||
{{UnderConstruction}} | {{UnderConstruction}} | ||
Revision as of 10:39, 9 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): QSystemDeviceInfo, QString, QStringList, QButton, QLabel |
Under Construction: This article is under construction and it may have outstanding issues. If you have any comments please use the comments tab.
Tip: Read this article before moving forward: Setting up environment for Qt Mobility API
Contents |
Overview
This is a part 1 of the QSystemDeviceInfo API which is a part of the System Information API from Qt Mobility project.
What is covered in QSystemDeviceInfo API Part 1
- It is a part of the System Information API.
- This article covers information about
Capabilities required
- ReadDeviceData
UI design (.ui file)
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
- Add required capability in .pro file as shown below:
symbian:TARGET.CAPABILITY = ReadDeviceData
Implementing QSystemDeviceInfo API
- QSystemDeviceInfo API is a part of the QtMobility namespace. So declare the QtMobility namespace as shown below:
using namespace QtMobility;
Header file
#ifndef SYSTEMDEVICEINFO_H
#define SYSTEMDEVICEINFO_H
#include <QtGui/QWidget>
#include "ui_SystemDeviceInfo.h"
#include <qsysteminfo.h>
using namespace QtMobility;
class SystemDeviceInfo : public QWidget
{
Q_OBJECT
public:
SystemDeviceInfo(QWidget *parent = 0);
~SystemDeviceInfo();
public slots:
void listDeviceInformation();
void resetAllFields();
private:
Ui::SystemDeviceInfo ui;
QSystemDeviceInfo* deviceInfo;
};
#endif // SYSTEMDEVICEINFO_H
Source file
#include "SystemDeviceInfo.h"
SystemDeviceInfo::SystemDeviceInfo(QWidget *parent)
: QWidget(parent), deviceInfo(NULL)
{
ui.setupUi(this);
deviceInfo = new QSystemDeviceInfo;
QObject::connect(ui.listDeviceInfoButton,
SIGNAL(clicked()),
this,
SLOT(listDeviceInformation()));
QObject::connect(ui.resetButton,
SIGNAL(clicked()),
this,
SLOT(resetAllFields()));
}
SystemDeviceInfo::~SystemDeviceInfo()
{
delete deviceInfo;
}
void SystemDeviceInfo::listDeviceInformation()
{
if(deviceInfo)
{
ui.imeiLabel->setText(deviceInfo->imei());
ui.imsiLabel->setText(deviceInfo->imsi());
ui.manufacturerLabel->setText(deviceInfo->manufacturer());
ui.modelLabel->setText(deviceInfo->model());
ui.productLabel->setText(deviceInfo->productName());
ui.batteryLabel->setText(QString::number(deviceInfo->batteryLevel()));
ui.batteryStatusLabel->setText(QString::number(
(QSystemDeviceInfo::BatteryStatus)deviceInfo->batteryStatus()));
ui.profileLabel->setText(QString::number(
(QSystemDeviceInfo::Profile)deviceInfo->currentProfile()));
ui.simLabel->setText(QString::number(
(QSystemDeviceInfo::SimStatus)deviceInfo->simStatus()));
ui.deviceLabel->setText(QString::number((int)deviceInfo->isDeviceLocked()));
}
}
void SystemDeviceInfo::resetAllFields()
{
if(deviceInfo)
{
ui.imeiLabel->clear();
ui.imsiLabel->clear();
ui.manufacturerLabel->clear();
ui.modelLabel->clear();
ui.productLabel->clear();
ui.batteryLabel->clear();
ui.batteryStatusLabel->clear();
ui.profileLabel->clear();
ui.simLabel->clear();
ui.deviceLabel->clear();
}
}
Output
Useful functions
Keywords
Headers
- #include <qsysteminfo.h>
Classes
- QSystemDeviceInfo
Example Application
- A working example application is available to download from here: QSystemDeviceInfo part1.zip
Related articles
- Getting started with Qt Mobility APIs
- Setting up environment for Qt Mobility API
- Working with QSystemInfo - System Information API - Part 1
- Working with QSystemInfo - System Information API - Part 2



