QWifiManager Class

Enables an application to be Wifi-capable. More...

Header: #include <QWifiManager>
Inherits: QObject

Public Types

enum BackendState { Initializing, Running, Terminating, NotRunning }
enum NetworkState { Disconnected, Authenticating, HandshakeFailed, ObtainingIPAddress, DhcpRequestFailed, Connected }
enum Roles { SSID, BSSID, SignalStrength, WPASupported, ..., WPSSupported }


  • 1 property inherited from QObject

Public Functions

virtual ~QWifiManager()
BackendState backendState() const
QString currentSSID() const
bool isScanning() const
QString lastError() const
NetworkState networkState() const
QAbstractListModel *networks() const
void setScanning(bool scanning)
  • 31 public functions inherited from QObject

Public Slots

bool connect(QWifiConfiguration *config)
void disconnect()
void start()
void stop()
  • 1 public slot inherited from QObject


void backendStateChanged(BackendState backendState)
void currentSSIDChanged(const QString &currentSSID)
void lastErrorChanged(const QString &error)
void networkStateChanged(NetworkState networkState)
void scanningChanged(bool scanning)

Static Public Members

QWifiManager *instance()
  • 10 static public members inherited from QObject

Reimplemented Protected Functions

virtual bool event(QEvent *event)
  • 9 protected functions inherited from QObject

Additional Inherited Members

  • 1 public variable inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

Enables an application to be Wifi-capable.

QWifiManager is a singleton class that handles Wifi-related tasks. You can use QWifiManager to control the Wifi backend, scan for Wifi access points, and connect to a wireless network.

QWifiManager packs the scan results in a list-based data model, which can be used with Qt's Model/View classes. Information about a Wifi network can be accessed using the QWifiManager::Roles data roles.

Member Type Documentation

enum QWifiManager::BackendState

Describes current state of the Wifi backend.

QWifiManager::Initializing0Wireless supplicant is starting up
QWifiManager::Running1Supplicant is initialized and ready to process commands
QWifiManager::Terminating2Shutting down wireless supplicant
QWifiManager::NotRunning3Wireless supplicant process is not running

enum QWifiManager::NetworkState

Describes current state of the network connection.

QWifiManager::Disconnected0Not connected to any network
QWifiManager::Authenticating1Verifying password with the network provider
QWifiManager::HandshakeFailed2Incorrect password provided
QWifiManager::ObtainingIPAddress3Requesting IP address from DHCP server
QWifiManager::DhcpRequestFailed4Could not retrieve IP address
QWifiManager::Connected5Ready to process network requests

enum QWifiManager::Roles

Data roles supported by the data model returned from QWifiManager::networks()

QWifiManager::SSIDQt::UserRole + 1informal (human) name of a Wifi network (QString)
QWifiManager::BSSIDQt::UserRole + 2basic service set identification of a network, used to uniquely identify BSS (QString)
QWifiManager::SignalStrengthQt::UserRole + 3strength of a Wifi signal represented as percentage (0-100) (int)
QWifiManager::WPASupportedQt::UserRole + 4holds whether network access point supports WPA security protocol (bool)
QWifiManager::WPA2SupportedQt::UserRole + 5holds whether network access point supports WPA2 security protocol (bool)
QWifiManager::WEPSupportedQt::UserRole + 6holds whether network access point supports WEP security protocol (bool)
QWifiManager::WPSSupportedQt::UserRole + 7holds whether network access point supports WPS security protocol (bool)

Property Documentation

backendState : const BackendState

This property holds the current backend state.

Returns the current backend state.

Access functions:

BackendState backendState() const

Notifier signal:

void backendStateChanged(BackendState backendState)

currentSSID : const QString

This property holds a network name of the last selected network.

The network for which the NetworkState change signals are emitted. Property can contain an empty string when there is no active network connection.

Access functions:

QString currentSSID() const

Notifier signal:

void currentSSIDChanged(const QString &currentSSID)

lastError : const QString

This property holds a QString containing the last error message set by QWifiManager.

Returns a QString containing the last error message set by QWifiManager. This helps in diagnosing the internal process failures.

Access functions:

QString lastError() const

Notifier signal:

void lastErrorChanged(const QString &error)

See also connect().

networkState : const NetworkState

This property holds the current network state.

Returns the current network state.

Access functions:

NetworkState networkState() const

Notifier signal:

void networkStateChanged(NetworkState networkState)

networks : QAbstractListModel * const

This property holds a list-based data model of networks.

Returns a list-based data model of networks that can be sensed by a device. Model can be used with Qt's Model/View classes such as QListView. Data in the model is updated every 5 seconds if scanning is enabled.

Access functions:

QAbstractListModel *networks() const

See also isScanning().

scanning : bool

This property holds whether the backend is scanning for Wifi networks.

Sets whether to scan the environment for Wifi access points.

To preserve battery energy, set this property to false when scanning is not required. When enabled, new readings are taken every 5 seconds.

Note: You must initialize the Wifi backend to scan for networks.

Access functions:

bool isScanning() const
void setScanning(bool scanning)

Notifier signal:

void scanningChanged(bool scanning)

See also start().

Member Function Documentation

[virtual] QWifiManager::~QWifiManager()

Destroys the QWifiManager singleton instance.

[slot] bool QWifiManager::connect(QWifiConfiguration *config)

Connect a device to a network using the config network configuration. This method returns true if the network with the provided configuration could be successfully added by the backend or false on failure. Use lastError() to obtain the error message on failure.

See also disconnect(), NetworkState, and lastError().

[slot] void QWifiManager::disconnect()

Disconnect from currently connected network connection.

See also connect() and networkState().

[virtual protected] bool QWifiManager::event(QEvent *event)

Reimplemented from QObject::event().

[static] QWifiManager *QWifiManager::instance()

Returns a singleton instance of QWifiManager.

[slot] void QWifiManager::start()

Start the Wifi backend. This function returns immediately, the BackendState change events are delivered asynchronously.

See also stop() and BackendState.

[slot] void QWifiManager::stop()

Stop the Wifi backend. Closes the open network connection if any. This function returns immediately, and the BackendState change events are delivered asynchronously.

See also start() and BackendState.

Available under certain Qt licenses.
Find out more.