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. Howto convert QOperatingSystemVersion::current() to string ?
QtWS25 Last Chance

Howto convert QOperatingSystemVersion::current() to string ?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 374 Views
  • 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.
  • P Offline
    P Offline
    pingal
    wrote on last edited by
    #1

    I need a runtime OS name and version. So i used

    qDebug() << QOperatingSystemVersion::current();
    

    Which returns

    QOperatingSystemVersion("Windows", 10.0.19043)
    

    I need this object to be converted to std::string Or QString like below

    Windows-10.0.19043
    
    JonBJ 1 Reply Last reply
    0
    • P pingal

      I need a runtime OS name and version. So i used

      qDebug() << QOperatingSystemVersion::current();
      

      Which returns

      QOperatingSystemVersion("Windows", 10.0.19043)
      

      I need this object to be converted to std::string Or QString like below

      Windows-10.0.19043
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @pingal
      So just use the documentation at https://doc.qt.io/qt-5/qoperatingsystemversion.html to pick out the members you wish to print --- it's just a normal class/struct --- using say QString::arg(...) for your desired format.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pingal
        wrote on last edited by pingal
        #3

        Sorry, I didn't get you.

        JonBJ 1 Reply Last reply
        0
        • P pingal

          Sorry, I didn't get you.

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

          @pingal
          I don't know what else to say. Look at the documentation, pick the members you want to include in your string like name() or majorVersion(), and use say QString::arg() to format them into the desired string. There is nothing especially "Qt" in accessing QOperatingSystemVersion() members, it's just like any other class.

          1 Reply Last reply
          2

          • Login

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