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. [SOLVED] How to determine which OS is program runnig on?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to determine which OS is program runnig on?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 5 Posters 4.7k 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.
  • S Offline
    S Offline
    soroush
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      steno
      wrote on last edited by
      #2

      I think the only way to tell is by using ifdef's....

      1 Reply Last reply
      0
      • R Offline
        R Offline
        renato.filho
        wrote on last edited by
        #3

        you can use the Qt Defines: Q_OS_WIN32, Q_OS_UNIX, Q_OS_LINUX, ...

        1 Reply Last reply
        0
        • S Offline
          S Offline
          soroush
          wrote on last edited by
          #4

          bq. you can use the Qt Defines: Q_OS_WIN32, Q_OS_UNIX, Q_OS_LINUX, …

          Thank you

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tomma
            wrote on last edited by
            #5

            Using QSettings with "SystemScope":http://doc.qt.nokia.com/4.7/qsettings.html#Scope-enum should select those config paths for you.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DeVeL-2010
              wrote on last edited by
              #6

              You can get more informations from QSysInfo if you have to distinguish further. Nevertheless you need the preprocessor symbols to use this class.

              1 Reply Last reply
              0

              • Login

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