Results 1 to 3 of 3

Thread: How to differentiate between operating systems inside the .cpp

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default How to differentiate between operating systems inside the .cpp

    Hello!

    Looking in Qwt examples I noticed that in the .pro file is possible to change the way the software is configured by putting some code inside a "label" defining for each operating system that code is valid. So for example, a code specific for Windows would be:

    Qt Code:
    1. win32 {
    2. .....
    3. }
    To copy to clipboard, switch view to plain text mode 

    while for linux:

    Qt Code:
    1. unix {
    2.  
    3. ...
    4.  
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 

    Now the problem is that I would like to have such possibility to be put inside the .cpp file. This is so because I'm developing a software in Linux but from time to time I have to pass it to Windows, and still of having to memorize each of the modifications I have to do when doing the change such possibility would help me making this process easier.

    So is there a way to say to my code that it has to use a specific part of it given one or other operating system as can be done in the .pro file?


    Thanks!


    Momergil

  2. #2
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: How to differentiate between operating systems inside the .cpp

    Use defines like Q_OS_WIN32 or Q_OS_UNIX, see Global Qt Declarations
    Oleg Shparber

  3. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to differentiate between operating systems inside the .cpp

    Quote Originally Posted by Oleg View Post
    Use defines like Q_OS_WIN32 or Q_OS_UNIX, see Global Qt Declarations

    Thanks!

    God bless,

    Momergil

Similar Threads

  1. Replies: 1
    Last Post: 27th September 2011, 07:08
  2. Replies: 1
    Last Post: 14th February 2010, 16:56
  3. Differentiate the icon and text in a QTreeView column
    By gmat4321 in forum Qt Programming
    Replies: 0
    Last Post: 25th February 2009, 15:38
  4. Replies: 1
    Last Post: 27th August 2007, 13:13
  5. QListWidget - inconsistency across operating systems?
    By scwizard in forum Qt Programming
    Replies: 20
    Last Post: 20th February 2007, 01:45

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.