Howto convert QOperatingSystemVersion::current() to string ?
-
wrote on 18 Feb 2022, 10:01 last edited by
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
-
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
wrote on 18 Feb 2022, 10:04 last edited by@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 normalclass
/struct
--- using sayQString::arg(...)
for your desired format. -
wrote on 18 Feb 2022, 10:21 last edited by pingal
Sorry, I didn't get you.
-
wrote on 18 Feb 2022, 10:38 last edited by
@pingal
I don't know what else to say. Look at the documentation, pick the members you want to include in your string likename()
ormajorVersion()
, and use sayQString::arg()
to format them into the desired string. There is nothing especially "Qt" in accessingQOperatingSystemVersion()
members, it's just like any other class.
2/4