QNetworkInformation#

QNetworkInformation exposes various network information through native backends. More

Inheritance diagram of PySide6.QtNetwork.QNetworkInformation

Synopsis#

Properties#

Functions#

Signals#

Static functions#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

QNetworkInformation provides a cross-platform interface to network-related information through plugins.

Various plugins can have various functionality supported, and so you can load() plugins based on which features are needed.

QNetworkInformation is a singleton and stays alive from the first successful load() until destruction of the QCoreApplication object. If you destroy and re-create the QCoreApplication object you must call load() again.

See also

Feature

class PySide6.QtNetwork.QNetworkInformation#

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property PᅟySide6.QtNetwork.QNetworkInformation.isBehindCaptivePortal: bool#

This property holds Lets you know if the user’s device is behind a captive portal..

This property indicates if the user’s device is currently known to be behind a captive portal. This functionality relies on the operating system’s detection of captive portals and is not supported on systems that don’t report this. On systems where this is not supported this will always return false.

Access functions:
property PᅟySide6.QtNetwork.QNetworkInformation.isMetered: bool#

This property holds Check if the current connection is metered.

This property returns whether the current connection is (known to be) metered or not. You can use this as a guiding factor to decide whether your application should perform certain network requests or uploads. For instance, you may not want to upload logs or diagnostics while this property is true.

Access functions:
property PᅟySide6.QtNetwork.QNetworkInformation.reachability: Reachability#

This property holds The current state of the system’s network connectivity..

Indicates the level of connectivity that can be expected. Do note that this is only based on what the plugin/operating system reports. In certain scenarios this is known to be wrong. For example, on Windows the ‘Online’ check, by default, is performed by Windows connecting to a Microsoft-owned server. If this server is for any reason blocked then it will assume it does not have Online reachability. Because of this you should not use this as a pre-check before attempting to make a connection.

Access functions:
property PᅟySide6.QtNetwork.QNetworkInformation.transportMedium: TransportMedium#

This property holds The currently active transport medium for the application.

This property returns the currently active transport medium for the application, on operating systems where such information is available.

When the current transport medium changes a signal is emitted, this can, for instance, occur when a user leaves the range of a WiFi network, unplugs their ethernet cable or enables Airplane mode.

Access functions:
PySide6.QtNetwork.QNetworkInformation.Reachability#

Constant

Description

QNetworkInformation.Reachability.Unknown

If this value is returned then we may be connected but the OS has still not confirmed full connectivity, or this feature is not supported.

QNetworkInformation.Reachability.Disconnected

Indicates that the system may have no connectivity at all.

QNetworkInformation.Reachability.Local

Indicates that the system is connected to a network, but it might only be able to access devices on the local network.

QNetworkInformation.Reachability.Site

Indicates that the system is connected to a network, but it might only be able to access devices on the local subnet or an intranet.

QNetworkInformation.Reachability.Online

Indicates that the system is connected to a network and able to access the Internet.

See also

reachability

PySide6.QtNetwork.QNetworkInformation.TransportMedium#

Lists the currently recognized media with which one can connect to the internet.

Constant

Description

QNetworkInformation.TransportMedium.Unknown

Returned if either the OS reports no active medium, the active medium is not recognized by Qt, or the TransportMedium feature is not supported.

QNetworkInformation.TransportMedium.Ethernet

Indicates that the currently active connection is using ethernet. Note: This value may also be returned when Windows is connected to a Bluetooth personal area network.

QNetworkInformation.TransportMedium.Cellular

Indicates that the currently active connection is using a cellular network.

QNetworkInformation.TransportMedium.WiFi

Indicates that the currently active connection is using Wi-Fi.

QNetworkInformation.TransportMedium.Bluetooth

Indicates that the currently active connection is connected using Bluetooth.

See also

transportMedium

New in version 6.3.

PySide6.QtNetwork.QNetworkInformation.Feature#

(inherits enum.Flag) Lists all of the features that a plugin may currently support. This can be used in QNetworkInformation::load().

Constant

Description

QNetworkInformation.Feature.Reachability

If the plugin supports this feature then the reachability property will provide useful results. Otherwise it will always return Reachability::Unknown. See also Reachability .

QNetworkInformation.Feature.CaptivePortal

If the plugin supports this feature then the isBehindCaptivePortal property will provide useful results. Otherwise it will always return false.

QNetworkInformation.Feature.TransportMedium

If the plugin supports this feature then the transportMedium property will provide useful results. Otherwise it will always return TransportMedium::Unknown. See also TransportMedium .

QNetworkInformation.Feature.Metered

If the plugin supports this feature then the isMetered property will provide useful results. Otherwise it will always return false.

static PySide6.QtNetwork.QNetworkInformation.availableBackends()#
Return type:

list of strings

Returns a list of the names of all currently available backends.

PySide6.QtNetwork.QNetworkInformation.backendName()#
Return type:

str

Returns the name of the currently loaded backend.

static PySide6.QtNetwork.QNetworkInformation.instance()#
Return type:

PySide6.QtNetwork.QNetworkInformation

Returns a pointer to the instance of the QNetworkInformation , if any.

See also

load()

PySide6.QtNetwork.QNetworkInformation.isBehindCaptivePortal()#
Return type:

bool

Getter of property isBehindCaptivePortal .

PySide6.QtNetwork.QNetworkInformation.isBehindCaptivePortalChanged(state)#
Parameters:

state – bool

Notification signal of property isBehindCaptivePortal .

PySide6.QtNetwork.QNetworkInformation.isMetered()#
Return type:

bool

Getter of property isMetered .

PySide6.QtNetwork.QNetworkInformation.isMeteredChanged(isMetered)#
Parameters:

isMetered – bool

Notification signal of property isMetered .

static PySide6.QtNetwork.QNetworkInformation.load(features)#
Parameters:

features – Combination of QNetworkInformation.Feature

Return type:

bool

Note

This function is deprecated.

Use loadBackendByFeatures() instead.

static PySide6.QtNetwork.QNetworkInformation.load(backend)
Parameters:

backend – str

Return type:

bool

Note

This function is deprecated.

Use loadBackendByName() instead.

static PySide6.QtNetwork.QNetworkInformation.loadBackendByFeatures(features)#
Parameters:

features – Combination of QNetworkInformation.Feature

Return type:

bool

Load a backend which supports features.

Returns true if it managed to load the requested backend or if it was already loaded. Returns false otherwise.

See also

instance

static PySide6.QtNetwork.QNetworkInformation.loadBackendByName(backend)#
Parameters:

backend – str

Return type:

bool

Attempts to load a backend whose name matches backend (case insensitively).

Returns true if it managed to load the requested backend or if it was already loaded. Returns false otherwise.

See also

instance

static PySide6.QtNetwork.QNetworkInformation.loadDefaultBackend()#
Return type:

bool

Attempts to load the platform-default backend.

This platform-to-plugin mapping is as follows:

Platform

Plugin-name

Windows

networklistmanager

Apple (macOS/iOS)

scnetworkreachability

Android

android

Linux

networkmanager

This function is provided for convenience where the default for a given platform is good enough. If you are not using the default plugins you must use one of the other load() overloads.

Returns true if it managed to load the backend or if it was already loaded. Returns false otherwise.

See also

instance() load()

PySide6.QtNetwork.QNetworkInformation.reachability()#
Return type:

Reachability

Getter of property reachability .

PySide6.QtNetwork.QNetworkInformation.reachabilityChanged(newReachability)#
Parameters:

newReachabilityReachability

Notification signal of property reachability .

PySide6.QtNetwork.QNetworkInformation.supportedFeatures()#
Return type:

Combination of QNetworkInformation.Feature

Returns all the supported features of the current backend.

PySide6.QtNetwork.QNetworkInformation.supports(features)#
Parameters:

features – Combination of QNetworkInformation.Feature

Return type:

bool

Returns true if the currently loaded backend supports features.

PySide6.QtNetwork.QNetworkInformation.transportMedium()#
Return type:

TransportMedium

Getter of property transportMedium .

PySide6.QtNetwork.QNetworkInformation.transportMediumChanged(current)#
Parameters:

currentTransportMedium

Notification signal of property transportMedium .