QNetworkInfo Class
The QNetworkInfo class provides various information about the network status. More...
Header: | #include <QNetworkInfo> |
Public Types
enum | CellDataTechnology { UnknownDataTechnology, GprsDataTechnology, EdgeDataTechnology, UmtsDataTechnology, HspaDataTechnology } |
enum | NetworkMode { UnknownMode, GsmMode, CdmaMode, WcdmaMode, WlanMode, …, TdscdmaMode } |
enum | NetworkStatus { UnknownStatus, NoNetworkAvailable, EmergencyOnly, Searching, Busy, …, Roaming } |
Public Functions
QNetworkInfo(QObject *parent = Q_NULLPTR) | |
virtual | ~QNetworkInfo() |
QString | cellId(int interfaceDevice) const |
QNetworkInfo::CellDataTechnology | currentCellDataTechnology(int interfaceDevice) const |
QString | currentMobileCountryCode(int interfaceDevice) const |
QString | currentMobileNetworkCode(int interfaceDevice) const |
QNetworkInfo::NetworkMode | currentNetworkMode() const |
QString | homeMobileCountryCode(int interfaceDevice) const |
QString | homeMobileNetworkCode(int interfaceDevice) const |
QString | imsi(int interfaceDevice) const |
QNetworkInterface | interfaceForMode(QNetworkInfo::NetworkMode mode, int interfaceDevice) const |
QString | locationAreaCode(int interfaceDevice) const |
QString | macAddress(QNetworkInfo::NetworkMode mode, int interfaceDevice) const |
int | networkInterfaceCount(QNetworkInfo::NetworkMode mode) const |
QString | networkName(QNetworkInfo::NetworkMode mode, int interfaceDevice) const |
int | networkSignalStrength(QNetworkInfo::NetworkMode mode, int interfaceDevice) const |
QNetworkInfo::NetworkStatus | networkStatus(QNetworkInfo::NetworkMode mode, int interfaceDevice) const |
Signals
void | cellIdChanged(int interface, const QString &id) |
void | currentCellDataTechnologyChanged(int interface, QNetworkInfo::CellDataTechnology tech) |
void | currentMobileCountryCodeChanged(int interface, const QString &mcc) |
void | currentMobileNetworkCodeChanged(int interface, const QString &mnc) |
void | currentNetworkModeChanged(QNetworkInfo::NetworkMode mode) |
void | locationAreaCodeChanged(int interface, const QString &lac) |
void | networkInterfaceCountChanged(QNetworkInfo::NetworkMode mode, int count) |
void | networkNameChanged(QNetworkInfo::NetworkMode mode, int interface, const QString &name) |
void | networkSignalStrengthChanged(QNetworkInfo::NetworkMode mode, int interface, int strength) |
void | networkStatusChanged(QNetworkInfo::NetworkMode mode, int interface, QNetworkInfo::NetworkStatus status) |
Detailed Description
To support the cases where one has multiple interfaces / modems for the same network mode, you can specify which interface you refer to. For those cases, the 'interface' parameter is the index of the interface, starting from 0.
Member Type Documentation
enum QNetworkInfo::CellDataTechnology
This enum describes the type of cellular technology.
Constant | Value | Description |
---|---|---|
QNetworkInfo::UnknownDataTechnology | 0 | The cellular technology is unknown or an error occured. |
QNetworkInfo::GprsDataTechnology | 1 | General Packet Radio Service (GPRS) data service. |
QNetworkInfo::EdgeDataTechnology | 2 | Enhanced Data Rates for GSM Evolution (EDGE) data service. |
QNetworkInfo::UmtsDataTechnology | 3 | Universal Mobile Telecommunications System (UMTS) data service. |
QNetworkInfo::HspaDataTechnology | 4 | High Speed Packet Access (HSPA) data service. |
enum QNetworkInfo::NetworkMode
This enumeration describes the type of the network.
Constant | Value | Description |
---|---|---|
QNetworkInfo::UnknownMode | 0 | The network is unknown or an error occured. |
QNetworkInfo::GsmMode | 1 | Global System for Mobile (GSM) network. |
QNetworkInfo::CdmaMode | 2 | Code Division Multiple Access (CDMA) network. |
QNetworkInfo::WcdmaMode | 3 | Wideband Code Division Multiple Access (WCDMA) network. |
QNetworkInfo::WlanMode | 4 | Wireless local area network (WLAN) network. |
QNetworkInfo::EthernetMode | 5 | Local area network (LAN), or Ethernet network. |
QNetworkInfo::BluetoothMode | 6 | Bluetooth network. |
QNetworkInfo::WimaxMode | 7 | Worldwide Interoperability for Microwave Access (WiMAX) network. |
QNetworkInfo::LteMode | 8 | 3GPP Long Term Evolution (LTE) network. |
QNetworkInfo::TdscdmaMode | 9 | Time Division Synchronous Code Division Multiple Access (TD-SCDMA) network. |
enum QNetworkInfo::NetworkStatus
This enumeration describes the status of the network.
Constant | Value | Description |
---|---|---|
QNetworkInfo::UnknownStatus | 0 | The status is unknown or an error occured. |
QNetworkInfo::NoNetworkAvailable | 1 | There is no network available. |
QNetworkInfo::EmergencyOnly | 2 | The network only allows emergency calls. |
QNetworkInfo::Searching | 3 | The device is searching or connecting to the network. |
QNetworkInfo::Busy | 4 | The network is too busy to be connected. |
QNetworkInfo::Denied | 5 | The connection to the network has been denied. |
QNetworkInfo::HomeNetwork | 6 | The device is connected to the home network. |
QNetworkInfo::Roaming | 7 | The device is connected to some roaming network. |
Member Function Documentation
QNetworkInfo::QNetworkInfo(QObject *parent = Q_NULLPTR)
Constructs a QNetworkInfo object with the given parent.
[signal]
void QNetworkInfo::cellIdChanged(int interface, const QString &id)
This signal is emitted whenever the cell ID for interface has changed to id.
[signal]
void QNetworkInfo::currentCellDataTechnologyChanged(int interface, QNetworkInfo::CellDataTechnology tech)
This signal is emitted whenever the current cell data technology for interface has changed to tech.
[signal]
void QNetworkInfo::currentMobileCountryCodeChanged(int interface, const QString &mcc)
This signal is emitted whenever the current Mobile Country Code (MCC) for interface has changed to mcc.
[signal]
void QNetworkInfo::currentMobileNetworkCodeChanged(int interface, const QString &mnc)
This signal is emitted whenever the current Mobile Network Code (MNC) for interface has changed to mnc.
[signal]
void QNetworkInfo::currentNetworkModeChanged(QNetworkInfo::NetworkMode mode)
This signal is emitted whenever the current network has changed to mode.
[signal]
void QNetworkInfo::locationAreaCodeChanged(int interface, const QString &lac)
This signal is emitted whenever the location area code for interface has changed to lac.
[signal]
void QNetworkInfo::networkInterfaceCountChanged(QNetworkInfo::NetworkMode mode, int count)
This signal is emitted whenever the number of interfaces for the mode has changed to count.
[signal]
void QNetworkInfo::networkNameChanged(QNetworkInfo::NetworkMode mode, int interface, const QString &name)
This signal is emitted whenever the name for the interface of mode has changed to name.
[signal]
void QNetworkInfo::networkSignalStrengthChanged(QNetworkInfo::NetworkMode mode, int interface, int strength)
This signal is emitted whenever the signal strength for the interface of mode has changed to strength.
[signal]
void QNetworkInfo::networkStatusChanged(QNetworkInfo::NetworkMode mode, int interface, QNetworkInfo::NetworkStatus status)
This signal is emitted whenever the status for the interface of mode has changed to status.
[virtual]
QNetworkInfo::~QNetworkInfo()
Destroys the object
QString QNetworkInfo::cellId(int interfaceDevice) const
Returns the cell ID of the connected tower or based station for interfaceDevice. If this information is not available or error occurs, an empty string is returned.
QNetworkInfo::CellDataTechnology QNetworkInfo::currentCellDataTechnology(int interfaceDevice) const
Returns the current cell data technology used for interfaceDevice.
QString QNetworkInfo::currentMobileCountryCode(int interfaceDevice) const
Returns the current Mobile Country Code (MCC) for interfaceDevice. An empty string is returned if the information is not available or an error occurs.
QString QNetworkInfo::currentMobileNetworkCode(int interfaceDevice) const
Returns the current Mobile Network Code (MNC) for interfaceDevice. An empty string is returned if the information is not available or an error occurs.
QNetworkInfo::NetworkMode QNetworkInfo::currentNetworkMode() const
Returns the current active network mode. If there are more than one modes activated, the preferred one is returned.
QString QNetworkInfo::homeMobileCountryCode(int interfaceDevice) const
Returns the home Mobile Country Code (MCC) for interfaceDevice. An empty string is returned if the information is not available or an error occurs.
QString QNetworkInfo::homeMobileNetworkCode(int interfaceDevice) const
Returns the home Mobile Network Code (MNC) for interfaceDevice. An empty string is returned if the information is not available or an error occurs.
QString QNetworkInfo::imsi(int interfaceDevice) const
Returns the International Mobile Subscriber Identity (IMSI) for interfaceDevice. If this information is not available, or error occurs, an empty string is returned.
QNetworkInterface QNetworkInfo::interfaceForMode(QNetworkInfo::NetworkMode mode, int interfaceDevice) const
Returns the first found interface for interfaceDevice of mode. If none is found, or it can't be represented by QNetworkInterface (e.g. Bluetooth), and empty object is returned.
QString QNetworkInfo::locationAreaCode(int interfaceDevice) const
Returns the location area code of the current cellular radio network for interfaceDevice. If this information is not available or error occurs, an empty string is returned.
QString QNetworkInfo::macAddress(QNetworkInfo::NetworkMode mode, int interfaceDevice) const
Returns the MAC address for interfaceDevice of mode. If the MAC address is not available or error occurs, an empty string is returned.
int QNetworkInfo::networkInterfaceCount(QNetworkInfo::NetworkMode mode) const
Returns the number of interfaces for the mode. If the information is not available, or error occurs, -1 is returned.
QString QNetworkInfo::networkName(QNetworkInfo::NetworkMode mode, int interfaceDevice) const
Returns the name of the operator for interfaceDevice of mode. If the information is not available, or an error occurs, an empty string is returned.
In case of WLAN, the SSID is returned; for Ethernet, the domain name is returned if available.
int QNetworkInfo::networkSignalStrength(QNetworkInfo::NetworkMode mode, int interfaceDevice) const
Returns the signal strength for interfaceDevice of mode, in 0 - 100 scale. If the information is not available, or error occurs, -1 is returned.
QNetworkInfo::NetworkStatus QNetworkInfo::networkStatus(QNetworkInfo::NetworkMode mode, int interfaceDevice) const
Returns the current status for interfaceDevice of mode.