System Version
-
Hi, I want to determine whether the calculated version is window 7 or window 10. I looked up the information and said it was using the QSysInfo class. But some of the apis in it seem to be deprecated. I am using 5.15.2. What is the alternative to the deprecated api?
-
@Nan-Feng
So for non-obsoleted, you have QSysInfo::productVersion(), QSysInfo::prettyProductName() and QSysInfo::kernelVersion().I imagine maintaining a list like the old QSysInfo::windowsVersion() got too old/tiresome for Qt to keep it going. Use a native Windows system call if you want information not provided by Qt.
-
call the DBMS interface to the windows registry and enter the correct SQL query to ask the registery.
-
Hello!
You can use the
QOperatingSystemVersion
class (https://doc.qt.io/qt-5/qoperatingsystemversion.html). Thecurrent()
method (https://doc.qt.io/qt-5/qoperatingsystemversion.html#current) returns the currentOS
and its version number. Feel free to check out my code below.Code:
QOperatingSystemVersion currentOSVersion = QOperatingSystemVersion::current(); if (currentOSVersion >= QOperatingSystemVersion::Windows10) { qDebug() << "Windows 10 build: " + QString("%1.%2.%3").arg(QString::number(QOperatingSystemVersion::current().majorVersion()), QString::number(QOperatingSystemVersion::current().minorVersion()), QString::number(QOperatingSystemVersion::current().microVersion())); } else if (currentOSVersion >= QOperatingSystemVersion::Windows7) { qDebug() << "Windows 7 build: " + QString("%1.%2.%3").arg(QString::number(QOperatingSystemVersion::current().majorVersion()), QString::number(QOperatingSystemVersion::current().minorVersion()), QString::number(QOperatingSystemVersion::current().microVersion())); }
My code only checks for
Win 10
andWin 7
, but you can check also for other operating systems for example:Win 8
andWin 8.1
. Happy coding!