QSysInfo Class
The QSysInfo class provides information about the system. More…
| Header | #include <QSysInfo> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
List of all members, including inherited members
Public Types
Static Public Members
Detailed Description
The class has only static functions. The build functions describe the system the program was compiled for, and the current functions the one it runs on, which may differ.
qDebug() << QSysInfo::prettyProductName() << QSysInfo::currentCpuArchitecture();
// "Ubuntu 24.04 LTS" "x86_64"
On Linux the product information comes from os-release(5), the kernel information from uname(2), and the identifiers from /etc/machine-id and /proc/sys/kernel/random/boot_id.
See also QOperatingSystemVersion.
Differences from Qt
There are no macVersion(), windowsVersion(), MacVersion or WinVersion members, which exist only on macOS and Windows.
Member Type Documentation
enum QSysInfo::Endian
| Constant | Description |
|---|---|
QSysInfo::BigEndian | Multi-byte values are stored with the most significant byte first. |
QSysInfo::LittleEndian | Multi-byte values are stored with the least significant byte first. |
QSysInfo::ByteOrder | The byte order of the platform the program was built for: BigEndian or LittleEndian. |
enum QSysInfo::Sizes
| Constant | Description |
|---|---|
QSysInfo::WordSize | The size in bits of a pointer on the platform the program was built for. |
Member Function Documentation
QByteArray QSysInfo::bootUniqueId()
Returns an identifier that is different after each boot of the machine, from /proc/sys/kernel/random/boot_id. Returns an empty array if the system has none.
See also machineUniqueId().
QString QSysInfo::buildAbi()
Returns the ABI that the program was built for as a string of the form architecture-endianness-wordsize, for example x86_64-little_endian-lp64.
See also buildCpuArchitecture().
QString QSysInfo::buildCpuArchitecture()
Returns the architecture of the CPU that the program was built for, such as x86_64, i386, arm64, arm or riscv64.
See also currentCpuArchitecture() and buildAbi().
QString QSysInfo::currentCpuArchitecture()
Returns the architecture of the CPU that the program is running on, which can differ from buildCpuArchitecture() when a 32-bit program runs on a 64-bit system or under emulation.
See also buildCpuArchitecture().
QString QSysInfo::kernelType()
Returns the lower-case name of the kernel, such as linux.
See also kernelVersion().
QString QSysInfo::kernelVersion()
Returns the release of the kernel, for example 6.8.0-45-generic.
See also kernelType().
QString QSysInfo::machineHostName()
Returns the host name of the machine, as set by the administrator, without the domain.
QByteArray QSysInfo::machineUniqueId()
Returns an identifier that is the same for the life of the installation of the operating system, from /etc/machine-id. Returns an empty array if the system has none. Do not use it as a secret.
See also bootUniqueId().
QString QSysInfo::prettyProductName()
Returns a name for the operating system that is suitable for showing to a user, such as Ubuntu 24.04 LTS, taken from the PRETTY_NAME entry of os-release. Falls back to the kernel name and release.
See also productType() and productVersion().
QString QSysInfo::productType()
Returns the identifier of the operating system product, such as ubuntu or fedora, taken from the ID entry of os-release. Returns unknown if the system does not say.
See also productVersion() and prettyProductName().
QString QSysInfo::productVersion()
Returns the version of the operating system product, such as 24.04, taken from the VERSION_ID entry of os-release. Returns unknown if the system does not say, as rolling releases do not.
See also productType().