IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QNetworkInformation Class

QNetworkInformation exposes various network information through native backends.

This class was introduced in Qt 6.1.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QNetworkInformation Class

  • Header: QNetworkInformation

  • Since: Qt 6.1

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Network)

    target_link_libraries(mytarget PRIVATE Qt6::Network)

  • qmake: QT += network

  • Inherits: QObject

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

Member Type Documentation

 

enum QNetworkInformation::Feature

flags QNetworkInformation::Features

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

Constant

Value

Description

QNetworkInformation::Feature::Reachability

0x1

If the plugin supports this feature then the reachability property will be available. See also QNetworkInformation::Reachability.

The Features type is a typedef for QFlags<Feature>. It stores an OR combination of Feature values.

enum QNetworkInformation::Reachability

Constant

Value

Description

QNetworkInformation::Reachability::Unknown

0

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

1

Indicates that the system may have no connectivity at all.

QNetworkInformation::Reachability::Local

2

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

3

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

4

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

See Also

Property Documentation

 

[read-only] reachability : const 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:

  • reachability() const

Notifier signal:

  • void reachabilityChanged( newReachability)

Member Function Documentation

 

[static] QStringList QNetworkInformation::availableBackends()

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

QString QNetworkInformation::backendName() const

Returns the name of the currently loaded backend.

[static] QNetworkInformation *QNetworkInformation::instance()

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

See Also

See also load()

[static] bool QNetworkInformation::load(QStringView backend)

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

See also instance

[static] bool QNetworkInformation::load(QNetworkInformation::Features features)

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

See also instance

bool QNetworkInformation::supports(QNetworkInformation::Features features) const

Returns true if the currently loaded backend supports features.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+