QOperatingSystemVersion 类提供有关操作系统版本的信息。 更多...
头: | #include <QOperatingSystemVersion> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
继承: | QOperatingSystemVersionBase |
enum | OSType { Android, IOS, MacOS, TvOS, WatchOS, …, Unknown } |
QOperatingSystemVersion (QOperatingSystemVersion::OSType osType , int vmajor , int vminor = -1, int vmicro = -1) | |
bool | isAnyOfType (std::initializer_list<OSType> 类型 ) const |
int | majorVersion () const |
int | microVersion () const |
int | minorVersion () const |
QString | name () const |
int | segmentCount () const |
QOperatingSystemVersion::OSType | type () const |
QVersionNumber | version () const |
const QOperatingSystemVersion | Android10 |
const QOperatingSystemVersion | Android11 |
const QOperatingSystemVersionBase | Android12 |
const QOperatingSystemVersionBase | Android13 |
const QOperatingSystemVersionBase | Android12L |
const QOperatingSystemVersion | AndroidJellyBean |
const QOperatingSystemVersion | AndroidJellyBean_MR1 |
const QOperatingSystemVersion | AndroidJellyBean_MR2 |
const QOperatingSystemVersion | AndroidKitKat |
const QOperatingSystemVersion | AndroidLollipop |
const QOperatingSystemVersion | AndroidLollipop_MR1 |
const QOperatingSystemVersion | AndroidMarshmallow |
const QOperatingSystemVersion | AndroidNougat |
const QOperatingSystemVersion | AndroidNougat_MR1 |
const QOperatingSystemVersion | AndroidOreo |
const QOperatingSystemVersion | AndroidOreo_MR1 |
const QOperatingSystemVersion | AndroidPie |
const QOperatingSystemVersion | MacOSBigSur |
const QOperatingSystemVersion | MacOSCatalina |
const QOperatingSystemVersion | MacOSHighSierra |
const QOperatingSystemVersion | MacOSMojave |
const QOperatingSystemVersion | MacOSMonterey |
const QOperatingSystemVersion | MacOSSierra |
const QOperatingSystemVersionBase | MacOSVentura |
const QOperatingSystemVersion | OSXElCapitan |
const QOperatingSystemVersion | OSXMavericks |
const QOperatingSystemVersion | OSXYosemite |
const QOperatingSystemVersion | Windows7 |
const QOperatingSystemVersion | Windows8 |
const QOperatingSystemVersion | Windows10 |
const QOperatingSystemVersionBase | Windows11 |
const QOperatingSystemVersionBase | Windows10_1809 |
const QOperatingSystemVersionBase | Windows10_1903 |
const QOperatingSystemVersionBase | Windows10_1909 |
const QOperatingSystemVersionBase | Windows10_20H2 |
const QOperatingSystemVersionBase | Windows10_2004 |
const QOperatingSystemVersionBase | Windows10_21H1 |
const QOperatingSystemVersionBase | Windows10_21H2 |
const QOperatingSystemVersionBase | Windows10_22H2 |
const QOperatingSystemVersionBase | Windows11_21H2 |
const QOperatingSystemVersionBase | Windows11_22H2 |
const QOperatingSystemVersion | Windows8_1 |
QOperatingSystemVersion | current () |
QOperatingSystemVersion::OSType | currentType () |
不像其它版本函数在 QSysInfo , QOperatingSystemVersion provides access to the full version number that developers typically use to vary behavior or determine whether to enable APIs or features based on the operating system version (as opposed to the kernel version number or marketing version).
Presently, Android, Apple Platforms (iOS, macOS, tvOS, and watchOS), and Windows are supported.
The majorVersion() , minorVersion() ,和 microVersion() functions return the parts of the operating system version number based on:
平台 | 值 |
---|---|
Android | result of parsing android.os.Build.VERSION.RELEASE 使用 QVersionNumber , with a fallback to android.os.Build.VERSION.SDK_INT to determine the major and minor version component if the former fails |
Apple Platforms | majorVersion , minorVersion , and patchVersion from NSProcessInfo.operatingSystemVersion |
Windows | dwMajorVersion, dwMinorVersion, and dwBuildNumber from RtlGetVersion - note that this function ALWAYS return the version number of the underlying operating system, as opposed to the shim underneath GetVersionEx that hides the real version number if the application is not manifested for that version of the OS |
Because QOperatingSystemVersion stores both a version number and an OS type, the OS type can be taken into account when performing comparisons. For example, on a macOS system running macOS Sierra (v10.12), the following expression will return
false
even though the major version number component of the object on the left hand side of the expression (10) is greater than that of the object on the right (9):
QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 9)
This allows expressions for multiple operating systems to be joined with a logical OR operator and still work as expected. For example:
auto current = QOperatingSystemVersion::current(); if (current >= QOperatingSystemVersion::OSXYosemite || current >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) { // returns true on macOS >= 10.10 and iOS >= 8.0, but false on macOS < 10.10 and iOS < 8.0 }
A more naive comparison algorithm might incorrectly return true on all versions of macOS, including Mac OS 9. This behavior is achieved by overloading the comparison operators to return
false
whenever the OS types of the QOperatingSystemVersion instances being compared do not match. Be aware that due to this it can be the case
x
>= y and
x
< y are BOTH
false
for the same instances of
x
and
y
.
This enum provides symbolic names for the various operating system families supported by QOperatingSystemVersion .
常量 | 值 | 描述 |
---|---|---|
QOperatingSystemVersion::Android
|
6
|
The Google Android operating system. |
QOperatingSystemVersion::IOS
|
3
|
The Apple iOS operating system. |
QOperatingSystemVersion::MacOS
|
2
|
The Apple macOS operating system. |
QOperatingSystemVersion::TvOS
|
4
|
The Apple tvOS operating system. |
QOperatingSystemVersion::WatchOS
|
5
|
The Apple watchOS operating system. |
QOperatingSystemVersion::Windows
|
1
|
The Microsoft Windows operating system. |
QOperatingSystemVersion::Unknown
|
0
|
An unknown or unsupported operating system. |
[constexpr]
QOperatingSystemVersion::
QOperatingSystemVersion
(
QOperatingSystemVersion::OSType
osType
,
int
vmajor
,
int
vminor
= -1,
int
vmicro
= -1)
Constructs a QOperatingSystemVersion consisting of the OS type osType , and major, minor, and micro version numbers vmajor , vminor and vmicro ,分别。
[static]
QOperatingSystemVersion
QOperatingSystemVersion::
current
()
返回 QOperatingSystemVersion 指示当前 OS (操作系统) 及其版本号。
另请参阅 currentType ().
[static constexpr]
QOperatingSystemVersion::OSType
QOperatingSystemVersion::
currentType
()
返回当前 OS 类型无需构造 QOperatingSystemVersion 实例。
另请参阅 current ().
Returns whether the OS type identified by the QOperatingSystemVersion matches any of the OS types in types .
[constexpr]
int
QOperatingSystemVersion::
majorVersion
() const
Returns the major version number, that is, the first segment of the operating system's version number.
See the main class documentation for what the major version number is on a given operating system.
-1 indicates an unknown or absent version number component.
另请参阅 version (), minorVersion (),和 microVersion ().
[constexpr]
int
QOperatingSystemVersion::
microVersion
() const
Returns the micro version number, that is, the third segment of the operating system's version number.
See the main class documentation for what the micro version number is on a given operating system.
-1 indicates an unknown or absent version number component.
另请参阅 version (), majorVersion (),和 minorVersion ().
[constexpr]
int
QOperatingSystemVersion::
minorVersion
() const
Returns the minor version number, that is, the second segment of the operating system's version number.
See the main class documentation for what the minor version number is on a given operating system.
-1 indicates an unknown or absent version number component.
另请参阅 version (), majorVersion (),和 microVersion ().
Returns a string representation of the OS type identified by the QOperatingSystemVersion .
另请参阅 type ().
[constexpr]
int
QOperatingSystemVersion::
segmentCount
() const
Returns the number of integers stored in the version number.
[constexpr]
QOperatingSystemVersion::OSType
QOperatingSystemVersion::
type
() const
Returns the OS type identified by the QOperatingSystemVersion .
另请参阅 name ().
[since 6.1]
QVersionNumber
QOperatingSystemVersion::
version
() const
Returns the operating system's version number.
See the main class documentation for what the version number is on a given operating system.
该函数在 Qt 6.1 引入。
另请参阅 majorVersion (), minorVersion (),和 microVersion ().
[since 6.1]
const
QOperatingSystemVersion
QOperatingSystemVersion::
Android10
This variable holds a version corresponding to Android 10 (version 10.0, API level 29).
This documentation was introduced in Qt 6.1.
[since 6.1]
const
QOperatingSystemVersion
QOperatingSystemVersion::
Android11
This variable holds a version corresponding to Android 11 (version 11.0, API level 30).
This documentation was introduced in Qt 6.1.
[since 6.5]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Android12
This variable holds a version corresponding to Android 12 (version 12.0, API level 31).
This documentation was introduced in Qt 6.5.
[since 6.5]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Android13
This variable holds a version corresponding to Android 13 (version 13.0, API level 33).
This documentation was introduced in Qt 6.5.
[since 6.5]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Android12L
This variable holds a version corresponding to Android 12L (version 12.0, API level 32).
This documentation was introduced in Qt 6.5.
This variable holds a version corresponding to Android Jelly Bean (version 4.1, API level 16).
This variable holds a version corresponding to Android Jelly Bean, maintenance release 1 (version 4.2, API level 17).
This variable holds a version corresponding to Android Jelly Bean, maintenance release 2 (version 4.3, API level 18).
This variable holds a version corresponding to Android KitKat (versions 4.4 & 4.4W, API levels 19 & 20).
This variable holds a version corresponding to Android Lollipop (version 5.0, API level 21).
This variable holds a version corresponding to Android Lollipop, maintenance release 1 (version 5.1, API level 22).
This variable holds a version corresponding to Android Marshmallow (version 6.0, API level 23).
This variable holds a version corresponding to Android Nougat (version 7.0, API level 24).
This variable holds a version corresponding to Android Nougat, maintenance release 1 (version 7.0, API level 25).
This variable holds a version corresponding to Android Oreo (version 8.0, API level 26).
[since 6.1]
const
QOperatingSystemVersion
QOperatingSystemVersion::
AndroidOreo_MR1
This variable holds a version corresponding to Android Oreo_MR1 (version 8.1, API level 27).
This documentation was introduced in Qt 6.1.
[since 6.1]
const
QOperatingSystemVersion
QOperatingSystemVersion::
AndroidPie
This variable holds a version corresponding to Android Pie (version 9.0, API level 28).
This documentation was introduced in Qt 6.1.
[since 6.0]
const
QOperatingSystemVersion
QOperatingSystemVersion::
MacOSBigSur
This variable holds a version corresponding to macOS Big Sur (version 11).
该文档编制在 Qt 6.0 引入。
This variable holds a version corresponding to macOS Catalina (version 10.15).
This variable holds a version corresponding to macOS High Sierra (version 10.13).
This variable holds a version corresponding to macOS Mojave (version 10.14).
[since 6.3]
const
QOperatingSystemVersion
QOperatingSystemVersion::
MacOSMonterey
This variable holds a version corresponding to macOS Monterey (version 12).
This documentation was introduced in Qt 6.3.
This variable holds a version corresponding to macOS Sierra (version 10.12).
[since 6.4]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
MacOSVentura
This variable holds a version corresponding to macOS Ventura (version 13).
This documentation was introduced in Qt 6.4.
此变量保持版本对应 OS X El Capitan (第 10.11 版)。
This variable holds a version corresponding to OS X Mavericks (version 10.9).
This variable holds a version corresponding to OS X Yosemite (version 10.10).
此变量保持版本对应 Windows 7 (第 6.1 版)。
此变量保持版本对应 Windows 8 (第 6.2 版)。
This variable holds a version corresponding to general Windows 10 (version 10.0).
[since 6.3]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Windows11
This variable holds a version corresponding to the initial release of Windows 11 (version 10.0.22000).
This documentation was introduced in Qt 6.3.
[since 6.3]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Windows10_1809
This variable holds a version corresponding to Windows 10 October 2018 Update Version 1809 (version 10.0.17763).
This documentation was introduced in Qt 6.3.
[since 6.3]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Windows10_1903
This variable holds a version corresponding to Windows 10 May 2019 Update Version 1903 (version 10.0.18362).
This documentation was introduced in Qt 6.3.
[since 6.3]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Windows10_1909
This variable holds a version corresponding to Windows 10 November 2019 Update Version 1909 (version 10.0.18363).
This documentation was introduced in Qt 6.3.
[since 6.3]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Windows10_20H2
This variable holds a version corresponding to Windows 10 October 2020 Update Version 20H2 (version 10.0.19042).
This documentation was introduced in Qt 6.3.
[since 6.3]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Windows10_2004
This variable holds a version corresponding to Windows 10 May 2020 Update Version 2004 (version 10.0.19041).
This documentation was introduced in Qt 6.3.
[since 6.3]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Windows10_21H1
This variable holds a version corresponding to Windows 10 May 2021 Update Version 21H1 (version 10.0.19043).
This documentation was introduced in Qt 6.3.
[since 6.3]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Windows10_21H2
This variable holds a version corresponding to Windows 10 November 2021 Update Version 21H2 (version 10.0.19044).
This documentation was introduced in Qt 6.3.
[since 6.5]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Windows10_22H2
This variable holds a version corresponding to Windows 10 October 2022 Update Version 22H2 (version 10.0.19045).
This documentation was introduced in Qt 6.5.
[since 6.4]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Windows11_21H2
This variable holds a version corresponding to Windows 11 Version 21H2 (version 10.0.22000).
This documentation was introduced in Qt 6.4.
[since 6.4]
const
QOperatingSystemVersionBase
QOperatingSystemVersion::
Windows11_22H2
This variable holds a version corresponding to Windows 11 Version 22H2 (version 10.0.22621).
This documentation was introduced in Qt 6.4.
此变量保持版本对应 Windows 8.1 (第 6.3 版)。