QOperatingSystemVersion Class
The QOperatingSystemVersion class provides information about the operating system version. More…
| Header | #include <QOperatingSystemVersion> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
List of all members, including inherited members
Public Types
| enum | OSType |
Public Functions
| QOperatingSystemVersion(OSType osType, int vmajor, int vminor = -1, int vmicro = -1) | |
| int | majorVersion() const |
| int | minorVersion() const |
| int | microVersion() const |
| int | segmentCount() const |
| QVersionNumber | version() const |
| OSType | type() const |
| QString | name() const |
| bool | isAnyOfType(std::initializer_list<OSType> types) const |
Static Public Members
| QOperatingSystemVersion | current() |
| OSType | currentType() |
Detailed Description
An object holds an operating system family and a version of up to three numbers. current() returns the system the program runs on; other objects can be constructed to compare against:
const QOperatingSystemVersion os = QOperatingSystemVersion::current();
if (os >= QOperatingSystemVersion(QOperatingSystemVersion::Unknown, 22))
qDebug() << os.name() << os.version();
The comparison operators only compare versions of the same operating system family; all of them are false for different families.
On Linux the type is Unknown, the name is the NAME entry of os-release, and the version comes from its VERSION_ID.
See also QSysInfo and QVersionNumber.
Differences from Qt
There are no static constants for versions of Windows, macOS, iOS, tvOS, watchOS, visionOS and Android, such as Windows10 or AndroidOreo, and no function that tests a platform-specific API level. There is no OSType value for Linux, as in Qt.
Member Type Documentation
enum QOperatingSystemVersion::OSType
The operating system families that Qt knows by name.
| Constant | Description |
|---|---|
QOperatingSystemVersion::Unknown | An operating system that has no value of its own; Linux and the other Unix systems are reported this way. |
QOperatingSystemVersion::Windows | Microsoft Windows. |
QOperatingSystemVersion::MacOS | Apple macOS. |
QOperatingSystemVersion::IOS | Apple iOS. |
QOperatingSystemVersion::TvOS | Apple tvOS. |
QOperatingSystemVersion::WatchOS | Apple watchOS. |
QOperatingSystemVersion::Android | Google Android. |
QOperatingSystemVersion::VisionOS | Apple visionOS. |
Member Function Documentation
QOperatingSystemVersion::QOperatingSystemVersion(OSType osType, int vmajor, int vminor = -1, int vmicro = -1)
Constructs a version of the operating system osType with the major version vmajor, the minor version vminor and the micro version vmicro. Pass -1 for the numbers that do not exist.
QOperatingSystemVersion QOperatingSystemVersion::current()
Returns the operating system the program is running on.
See also currentType().
OSType QOperatingSystemVersion::currentType()
Returns the type of the operating system the program is running on, which is always Unknown on Linux.
See also current().
bool QOperatingSystemVersion::isAnyOfType(std::initializer_list<OSType> types) const
Returns true if the operating system family is one of types.
int QOperatingSystemVersion::majorVersion() const
Returns the major version number, or -1 if there is none.
int QOperatingSystemVersion::microVersion() const
Returns the micro version number, or -1 if there is none.
int QOperatingSystemVersion::minorVersion() const
Returns the minor version number, or -1 if there is none.
QString QOperatingSystemVersion::name() const
Returns the name of the operating system, such as Ubuntu on Linux or Windows. Returns Unknown if it has none.
int QOperatingSystemVersion::segmentCount() const
Returns the number of version numbers that are set: 0 to 3.
OSType QOperatingSystemVersion::type() const
Returns the operating system family.
QVersionNumber QOperatingSystemVersion::version() const
Returns the version as a QVersionNumber with as many segments as are set.