QOperatingSystemVersion露
- PyQt5.QtCore.QOperatingSystemVersion
Description露
The QOperatingSystemVersion class provides information about the operating system version.
Unlike other version functions in 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).
This class is also a complete replacement for QSysInfo::macVersion and QSysInfo::windowsVersion, additionally providing access to the third (micro) version number component.
Presently, Android, Apple Platforms (iOS, macOS, tvOS, and watchOS), and Windows are supported.
The majorVersion(), minorVersion(), and microVersion() functions return the parts of the operating system version number based on:
Platforms |
Value |
---|---|
Android |
result of parsing android.os.Build.VERSION.RELEASE using 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
.
Enums露
- OSType
This enum provides symbolic names for the various operating system families supported by QOperatingSystemVersion.
Member
Value
Description
Android 6
The Google Android operating system.
IOS 3
The Apple iOS operating system.
MacOS 2
The Apple macOS operating system.
TvOS 4
The Apple tvOS operating system.
Unknown 0
An unknown or unsupported operating system.
WatchOS 5
The Apple watchOS operating system.
Windows 1
The Microsoft Windows operating system.
Attributes露
- AndroidJellyBean: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Android Jelly Bean (version 4.1, API level 16)..
- AndroidJellyBean_MR1: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Android Jelly Bean, maintenance release 1 (version 4.2, API level 17)..
- AndroidJellyBean_MR2: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Android Jelly Bean, maintenance release 2 (version 4.3, API level 18)..
- AndroidKitKat: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Android KitKat (versions 4.4 & 4.4W, API levels 19 & 20)..
- AndroidLollipop: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Android Lollipop (version 5.0, API level 21)..
- AndroidLollipop_MR1: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Android Lollipop, maintenance release 1 (version 5.1, API level 22)..
- AndroidMarshmallow: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Android Marshmallow (version 6.0, API level 23)..
- AndroidNougat: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Android Nougat (version 7.0, API level 24)..
- AndroidNougat_MR1: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Android Nougat, maintenance release 1 (version 7.0, API level 25)..
- AndroidOreo: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Android Oreo (version 8.0, API level 26)..
- MacOSCatalina: QOperatingSystemVersion
This is a read-only class attribute.
TODO
- MacOSHighSierra: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to macOS High Sierra (version 10.13)..
- MacOSMojave: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to macOS Mojave (version 10.14)..
- MacOSSierra: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to macOS Sierra (version 10.12)..
- OSXElCapitan: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to OS X El Capitan (version 10.11)..
- OSXMavericks: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to OS X Mavericks (version 10.9)..
- OSXYosemite: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to OS X Yosemite (version 10.10)..
- Windows10: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Windows 10 (version 10.0)..
- Windows7: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Windows 7 (version 6.1)..
- Windows8: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Windows 8 (version 6.2)..
- Windows8_1: QOperatingSystemVersion
This is a read-only class attribute.
This variable holds a version corresponding to Windows 8.1 (version 6.3)..
Methods露
- __init__(QOperatingSystemVersion)
TODO
- __init__(OSType, int, vminor: int = -1, vmicro: int = -1)
TODO
-
@staticmethod
current() → QOperatingSystemVersion TODO
-
@staticmethod
currentType() → OSType TODO
- __ge__(QOperatingSystemVersion) → bool
TODO
- __gt__(QOperatingSystemVersion) → bool
TODO
- __le__(QOperatingSystemVersion) → bool
TODO
- __lt__(QOperatingSystemVersion) → bool
TODO
- majorVersion() → int
TODO
- microVersion() → int
TODO
- minorVersion() → int
TODO
- name() → str
TODO
- segmentCount() → int
TODO
- type() → OSType
TODO