Results 1 to 8 of 8

Thread: QMake DEFINES

  1. #1
    Join Date
    Nov 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QMake DEFINES

    How can I add a string define to the preprocessor using qmake? I'm looking for a way to do the following, but it does not work.

    DEFINES += MY_DEFINE="FOO BAR"

    Please help me.

  2. #2
    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: QMake DEFINES

    Try this:
    qmake Code:
    1. DEFINES += "MY_DEFINE=\"FOO BAR\""
    To copy to clipboard, switch view to plain text mode 
    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.


  3. #3
    Join Date
    Nov 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMake DEFINES

    No, that does not work. In this case Moc fails.

  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: QMake DEFINES

    Fails on what? What is the exact error? Try this too:
    qmake Code:
    1. DEFINES += "MY_DEFINE=FOO_BAR" # no space between FOO and BAR allowed
    To copy to clipboard, switch view to plain text mode 

    It works fine for me, by the way...
    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. #5
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMake DEFINES

    Quote Originally Posted by AlHadr View Post
    How can I add a string define to the preprocessor using qmake? I'm looking for a way to do the following, but it does not work.

    DEFINES += MY_DEFINE="FOO BAR"
    Guess your DEFINES don't appear in your Makefile, right?

    May be the problem has been solved already, but if not try

    qmake -Wall -Wparser -Wlogic your_pro_file.pro

    Guenther

  6. #6
    Join Date
    May 2009
    Posts
    56
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QMake DEFINES

    Hi there,

    What about if you want to define the FILEVERSION (without the quotes) For the resource file(windows),
    something like this:

    DEFINES+= PROD_VER=5,6,4,5

    how this could be done?
    Last edited by cafu1007; 29th March 2011 at 17:53.

  7. #7
    Join Date
    Nov 2011
    Posts
    1
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QMake DEFINES

    Qt Code:
    1. defines += 'my_define=\'\"foo bar\"\''
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Sep 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QMake DEFINES

    I solved it like this

    DEFINES += MY_DEFINE=\\\"FOO BAR\\\"

Similar Threads

  1. QMAKE custom DEFINES & CONFIG
    By sheeeng in forum Qt Programming
    Replies: 16
    Last Post: 12th January 2012, 17:04
  2. Date defines in Sqlite?
    By Raccoon29 in forum General Programming
    Replies: 1
    Last Post: 24th November 2009, 00:14
  3. Passing global defines to moc
    By NTwoO in forum Qt Programming
    Replies: 6
    Last Post: 2nd April 2007, 12:23
  4. Adding custom defines when on debug build
    By chus in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2007, 12:38
  5. Qt4 Preprocessor defines
    By Chicken Blood Machine in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 17:28

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.