[SOLVED] How to determine which OS is program runnig on?
-
Hello
I would like to specify some paths at runtime, depending on Operating System. for example if application is running on windows, the configuration file is in <application directory>\config\defaults.conf. else if it's running on Linux, then configuration file is in /etc/<application>/defaults.conf.
What is the most compatible way to determine which OS is running? Currently I'm doing:
@#ifdef _WIN32@
Does Qt have a better way? -
I think the only way to tell is by using ifdef's....
-
you can use the Qt Defines: Q_OS_WIN32, Q_OS_UNIX, Q_OS_LINUX, ...
-
bq. you can use the Qt Defines: Q_OS_WIN32, Q_OS_UNIX, Q_OS_LINUX, …
Thank you
-
Using QSettings with "SystemScope":http://doc.qt.nokia.com/4.7/qsettings.html#Scope-enum should select those config paths for you.
-
You can get more informations from QSysInfo if you have to distinguish further. Nevertheless you need the preprocessor symbols to use this class.