QSysInfo class provides all information about the underlying system in which we run our application. This class provide information about the following features of the system.
- Byte Order – platform is big-endian or little-endian
- Windows Version – version of the Windows operating system
- Macintosh Version – version of the Macintosh operating system
- CPU Architecture – architecture of the CPU
Some of these constants will be available for specific operating system so we can use pre-processing symbols like Q_OS_WIN or Q_OS_OSX to check that the application is compiled under Windows or OS X.
Following is the sample code snippet which shows how to use this class to get the information about the system.
QSysInfo systemInfo; qDebug()<< "Windows Version: " << systemInfo.windowsVersion(); qDebug()<< "Build Cpu Architecture: " << systemInfo.buildCpuArchitecture(); qDebug()<< "Current Cpu Architecture: " << systemInfo.currentCpuArchitecture(); qDebug()<< "Kernel Type: " << systemInfo.kernelType(); qDebug()<< "Kernel Version: " << systemInfo.kernelVersion(); qDebug()<< "Machine Host Name: " << systemInfo.machineHostName(); qDebug()<< "Product Type: " << systemInfo.productType(); qDebug()<< "Product Version: " << systemInfo.productVersion(); qDebug()<< "Byte Order: " << systemInfo.buildAbi(); qDebug()<< "Pretty ProductName: " << systemInfo.prettyProductName();
Output: Windows Version: 192 Build Cpu Architecture: "i386" Current Cpu Architecture: "x86_64" Kernel Type: "winnt" Kernel Version: "10.0.10586" Machine Host Name: "My Computer" Product Type: "windows" Product Version: "10" Byte Order: "i386-little_endian-ilp32" Pretty ProductName: "Windows 10"
For additional information refer Qt docs QSysInfo.