Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qnetworkinformation.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QNETWORKINFORMATION_H
5#define QNETWORKINFORMATION_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtCore/qobject.h>
9#include <QtCore/qstringview.h>
10#include <QtCore/qstringlist.h>
11
13
17class Q_NETWORK_EXPORT QNetworkInformation : public QObject
18{
20 Q_DECLARE_PRIVATE(QNetworkInformation)
21 Q_PROPERTY(Reachability reachability READ reachability NOTIFY reachabilityChanged)
22 Q_PROPERTY(bool isBehindCaptivePortal READ isBehindCaptivePortal
23 NOTIFY isBehindCaptivePortalChanged)
24 Q_PROPERTY(TransportMedium transportMedium READ transportMedium NOTIFY transportMediumChanged)
25 Q_PROPERTY(bool isMetered READ isMetered NOTIFY isMeteredChanged)
26 Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
27public:
28 enum class Reachability {
29 Unknown,
30 Disconnected,
31 Local,
32 Site,
33 Online,
34 };
35 Q_ENUM(Reachability)
36
37 enum class TransportMedium {
38 Unknown,
39 Ethernet,
40 Cellular,
41 WiFi,
42 Bluetooth,
43 };
44 Q_ENUM(TransportMedium)
45
46 enum class Feature {
47 Reachability = 0x1,
48 CaptivePortal = 0x2,
49 TransportMedium = 0x4,
50 Metered = 0x8,
51 };
52 Q_DECLARE_FLAGS(Features, Feature)
53 Q_FLAG(Features)
54
55 Reachability reachability() const;
56
57 bool isBehindCaptivePortal() const;
58
59 TransportMedium transportMedium() const;
60
61 bool isMetered() const;
62
63 QString backendName() const;
64
65 bool supports(Features features) const;
66 Features supportedFeatures() const;
67
68 static bool loadDefaultBackend();
69 static bool loadBackendByName(QStringView backend);
70 static bool loadBackendByFeatures(Features features);
71#if QT_DEPRECATED_SINCE(6,4)
72 QT_DEPRECATED_VERSION_X_6_4("Use loadBackendByName") static bool load(QStringView backend);
73 QT_DEPRECATED_VERSION_X_6_4("Use loadBackendByFeatures") static bool load(Features features);
74#endif
75 static QStringList availableBackends();
76 static QNetworkInformation *instance();
77
79 void reachabilityChanged(Reachability newReachability);
82 void isMeteredChanged(bool isMetered);
83
84private:
88
89 Q_DISABLE_COPY_MOVE(QNetworkInformation)
90};
91
92Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkInformation::Features)
93
95
96#endif
static void transportMediumChanged(JNIEnv *env, jobject obj, jint enumValue)
QNetworkInformationBackend provides the interface with which QNetworkInformation does all of its actu...
\inmodule QtNetwork
void transportMediumChanged(TransportMedium current)
void isMeteredChanged(bool isMetered)
void reachabilityChanged(Reachability newReachability)
Reachability
\value Unknown If this value is returned then we may be connected but the OS has still not confirmed ...
void isBehindCaptivePortalChanged(bool state)
Feature
Lists all of the features that a plugin may currently support.
~QNetworkInformation() override
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:78
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
p1 load("image.bmp")
else opt state
[0]
Combined button and popup list for selecting options.
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
static QString backendName
#define QT_DEPRECATED_VERSION_X_6_4(text)
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_CLASSINFO(name, value)
#define Q_FLAG(x)
#define Q_SIGNALS