×
Namespaces

Variants
Actions
Revision as of 08:06, 11 February 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Working with QSystemNetworkInfo - System Information API - Part 1

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 xPressMusic
CompatibilityPlatform Security
Signing Required: DevCert
Capabilities: ReadDeviceData
Article
Keywords: QSystemNetworkInfo, QString, QButton, QLabel, QComboBox
Created: kiran10182 (15 Mar 2010)
Last edited: hamishwillee (11 Feb 2013)

Tip.pngTip: 


Contents

Overview

This is a part 1 of the QSystemNetworkInfo API which is a part of the System Information API from Qt Mobility project. The part 2 of this article can be read from here

What is covered in QSystemNetworkInfo API Part 1

  • It is a part of the System Information API.
  • This article covers information about
    • Cell ID of the network
    • Mobile Country code
    • Mobile Network code
    • Home Mobile Country code
    • Home Mobile Network code
    • Location Area code
    • Network name
    • Network Signal strength


Capabilities required

  • ReadDeviceData


UI design (.ui file)

QSystemNetworkInfo-1 UI.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 required capability in .pro file as shown below:
symbian:TARGET.CAPABILITY = ReadDeviceData

Implementing QSystemNetworkInfo API

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

Header file

#ifndef SYSTEMNETWORKINFO_H
#define SYSTEMNETWORKINFO_H
 
#include <QtGui/QWidget>
#include "ui_SystemNetworkInfo.h"
#include <qsysteminfo.h>
 
using namespace QtMobility;
class SystemNetworkInfo : public QWidget
{
Q_OBJECT
 
public:
SystemNetworkInfo(QWidget *parent = 0);
~SystemNetworkInfo();
public slots:
void displayNetworkInfo(int aIndex);
void resetAllFields();
 
private:
Ui::SystemNetworkInfo ui;
QSystemNetworkInfo* networkInfo;
};
 
#endif // SYSTEMNETWORKINFO_H


Source file

#include "SystemNetworkInfo.h"
 
SystemNetworkInfo::SystemNetworkInfo(QWidget *parent)
: QWidget(parent), networkInfo(NULL)
{
ui.setupUi(this);
networkInfo = new QSystemNetworkInfo();
QObject::connect(ui.comboBox,
SIGNAL(currentIndexChanged(int)),
this,
SLOT(displayNetworkInfo(int)));
QObject::connect(ui.resetButton,
SIGNAL(clicked()),
this,
SLOT(resetAllFields()));
}
 
SystemNetworkInfo::~SystemNetworkInfo()
{
delete networkInfo;
networkInfo = NULL;
}
 
void SystemNetworkInfo::displayNetworkInfo(int aIndex)
{
if(! aIndex)
{
ui.resultLabel->clear();
return;
}
 
QString result;
switch(aIndex)
{
case 1:
{
result = QString::number(networkInfo->cellId());
break;
}
case 2:
{
result = networkInfo->currentMobileCountryCode();
break;
}
case 3:
{
result = networkInfo->currentMobileNetworkCode();
break;
}
case 4:
{
result = networkInfo->homeMobileCountryCode();
break;
}
case 5:
{
result = networkInfo->homeMobileNetworkCode();
break;
}
case 6:
{
result = QString::number(networkInfo->locationAreaCode());
break;
}
case 7:
{
result = networkInfo->networkName(QSystemNetworkInfo::GsmMode);
break;
}
case 8:
{
result = QString::number(networkInfo->networkSignalStrength(
QSystemNetworkInfo::GsmMode));
break;
}
default:
{
break;
}
}
if(! result.length())
{
result = ("Not available");
}
ui.resultLabel->setText(result);
}
 
void SystemNetworkInfo::resetAllFields()
{
ui.resultLabel->clear();
ui.comboBox->setCurrentIndex(0);
}


Output

QSystemNetworkInfo-1 device.jpg


Useful functions

  • int cellId ();
  • QString currentMobileCountryCode ();
  • QString currentMobileNetworkCode ();
  • QString homeMobileCountryCode ();
  • QString homeMobileNetworkCode ();
  • int locationAreaCode ();
  • QString networkName ( QSystemNetworkInfo::NetworkMode mode );
  • int networkSignalStrength ( QSystemNetworkInfo::NetworkMode mode );

Keywords

Headers

  • #include <qsysteminfo.h>

Classes

  • QSystemNetworkInfo
  • QString
  • QButton
  • QLabel
  • QComboBox


Example Application


Related articles

Reference links

Version Hint

Windows Phone: [[Category:Windows Phone]]
[[Category:Windows Phone 7.5]]
[[Category:Windows Phone 8]]

Nokia Asha: [[Category:Nokia Asha]]
[[Category:Nokia Asha Platform 1.0]]

Series 40: [[Category:Series 40]]
[[Category:Series 40 1st Edition]] [[Category:Series 40 2nd Edition]]
[[Category:Series 40 3rd Edition (initial release)]] [[Category:Series 40 3rd Edition FP1]] [[Category:Series 40 3rd Edition FP2]]
[[Category:Series 40 5th Edition (initial release)]] [[Category:Series 40 5th Edition FP1]]
[[Category:Series 40 6th Edition (initial release)]] [[Category:Series 40 6th Edition FP1]] [[Category:Series 40 Developer Platform 1.0]] [[Category:Series 40 Developer Platform 1.1]] [[Category:Series 40 Developer Platform 2.0]]

Symbian: [[Category:Symbian]]
[[Category:S60 1st Edition]] [[Category:S60 2nd Edition (initial release)]] [[Category:S60 2nd Edition FP1]] [[Category:S60 2nd Edition FP2]] [[Category:S60 2nd Edition FP3]]
[[Category:S60 3rd Edition (initial release)]] [[Category:S60 3rd Edition FP1]] [[Category:S60 3rd Edition FP2]]
[[Category:S60 5th Edition]]
[[Category:Symbian^3]] [[Category:Symbian Anna]] [[Category:Nokia Belle]]

This page was last modified on 11 February 2013, at 08:06.
72 page views in the last 30 days.
×