Results 1 to 5 of 5

Thread: How to know the operating system?

  1. #1
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question How to know the operating system?

    Hi there, I wanto to know wha'ts the best/easy way to know in wich operating system the application is running. I need to know it because I want to execute different instructions depending on the OS...

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to know the operating system?

    use #ifdef WIN32

    It tells you that the OS is some windows flavor. Likewise there are macros defined for *nix and mac. But I don't knw the words used for *nix and mac. I think it should be UNIX and MAC

  3. The following user says thank you to munna for this useful post:

    Dark_Tower (1st May 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to know the operating system?

    The "Assistant" has a topic called:
    Qt Code:
    1. All Overviews and HOWTOs
    To copy to clipboard, switch view to plain text mode 
    and under it is another topic:
    Qt Code:
    1. Window System Specific Notes
    To copy to clipboard, switch view to plain text mode 
    The second tells you all you need to know, with examples.

  5. The following user says thank you to GreyGeek for this useful post:

    Dark_Tower (4th May 2006)

  6. #4
    Join Date
    Jan 2006
    Location
    Cambridge, MA
    Posts
    32
    Thanked 7 Times in 6 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to know the operating system?

    There are a couple thing Qt does for you to let you know at compile time what OS you are compiling for. Of course Qt is "Write once, Compile Everywhere". There are some generic defines based on your windowing system like

    Q_WS_X11
    Q_WS_WIN
    Q_WS_MAC

    This can narrow things down quite a bit sine you can say if I'm on windows do the win32 thing else do the POSIX thing.

    There are some OS specific ones but they are too specific for most applications

    Q_OS_IRIX
    Q_OS_LINUX
    Q_OS_FREEBSD
    Q_OS_BSD4
    Q_OS_WIN32

    These can help you when you want a list of network interface on IRIX etc. Where code varies greatly between very specific OSs.

    Of course see Assistant for a full list.

    --Justin Noel
    justin@ics.com

  7. The following user says thank you to Glitch for this useful post:

    Dark_Tower (4th May 2006)

  8. #5
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to know the operating system?

    you may also have a look at QSysInfo. In combination with these macros it allows you to determine what version of Window$ or Mac OS X are running, which can be useful if your app use a component that is not provided by Win9x but by WinXP...
    Current Qt projects : QCodeEdit, RotiDeCode

Similar Threads

  1. Locating a driver on the operating system
    By schall_l in forum Qt Programming
    Replies: 2
    Last Post: 15th July 2008, 10:19
  2. QMainWindow in AIX operating system
    By Vani in forum Qt Programming
    Replies: 3
    Last Post: 14th June 2008, 20:50
  3. change operating system theme.
    By rajeshs in forum Qt Programming
    Replies: 2
    Last Post: 20th March 2008, 05:02
  4. Access to PostgreSQL DB on a linux server
    By rmagro in forum Qt Programming
    Replies: 28
    Last Post: 13th March 2008, 10:02
  5. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 14:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.