Results 1 to 5 of 5

Thread: How use conditions in Qt .pro file

  1. #1
    Join Date
    Dec 2009
    Posts
    62
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default How use conditions in Qt .pro file

    Hi

    I want to do something like this in order to stub out parts of my code when building but I do not know how to achive something similar to ifdef in the Qt pro file:

    I would like to do this:

    DEFINES += USE_LIBS // I want to build with all my libs

    ifdef USE_LIBS
    LIBS+= -lmylib1 -lmyLib2
    else
    //Stub out parts of the app by not including the libs. The USE_LIBS will be 0 and the corresponding includes in the code will be removed with the USE_LIBS define.
    endif

    Can this conditional building be done in the pro file, if not how can I achive this?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: How use conditions in Qt .pro file

    Yes you can do that.
    Check out http://doc.qt.nokia.com/4.6/qmake-manual.html

  3. #3
    Join Date
    Jan 2008
    Location
    Germany
    Posts
    80
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How use conditions in Qt .pro file

    Do you have an example ?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How use conditions in Qt .pro file

    qmake Code:
    1. use_libs {
    2. LIBS += -lmylib1 -lmylib2
    3. } else {
    4. # Stub out parts of the app by not including the libs.
    5. }
    To copy to clipboard, switch view to plain text mode 

    Then call qmake CONFIG+=use_libs
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    frankiefrank (14th October 2013)

  6. #5
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How use conditions in Qt .pro file

    Thank you wysota! You helped me to get on the right track!

Similar Threads

  1. Replies: 4
    Last Post: 9th May 2010, 16:18
  2. Replies: 3
    Last Post: 15th February 2010, 17:27
  3. Replies: 3
    Last Post: 28th March 2009, 15:37
  4. Replies: 3
    Last Post: 25th May 2007, 07:49
  5. Low-level error conditions on QImage.load()
    By bruccutler in forum Newbie
    Replies: 3
    Last Post: 19th January 2007, 21:09

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.