Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. System Version
Forum Updated to NodeBB v4.3 + New Features

System Version

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 493 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nan Feng
    wrote on last edited by
    #1

    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?

    JonBJ 1 Reply Last reply
    0
    • N Nan Feng

      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?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @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.

      1 Reply Last reply
      1
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        call the DBMS interface to the windows registry and enter the correct SQL query to ask the registery.

        1 Reply Last reply
        1
        • Cobra91151C Offline
          Cobra91151C Offline
          Cobra91151
          wrote on last edited by
          #4

          Hello!

          You can use the QOperatingSystemVersion class (https://doc.qt.io/qt-5/qoperatingsystemversion.html). The current() method (https://doc.qt.io/qt-5/qoperatingsystemversion.html#current) returns the current OS 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 and Win 7, but you can check also for other operating systems for example: Win 8 and Win 8.1. Happy coding!

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved