[solved] qmake configurations for target device



  • How do I define configurations to include a different set of resources for each target device? I managed to define macros that are visible inside .cpp/.h sources: In MyProject.pro I included the following lines:

    @
    DEFINES +=
    USE_THEME_ANDROID_HOLOLIGHT=1
    USE_THEME_ANDROID_HOLODARK=0
    USE_THEME_IOS=0
    @

    To use a different set of icons, I tried the following:

    @

    (USE_THEME_ANDROID_HOLOLIGHT == 1) {
    RESOURCES += images/android-holo-light/android-holo-light.qrc
    }
    (USE_THEME_ANDROID_HOLODARK == 1) {
    RESOURCES += images/android-holo-dark/android-holo-dark.qrc
    }
    (USE_THEME_IOS == 1) {
    RESOURCES += images/ios/ios.qrc
    }
    @

    However, this does not seem to be syntactically correct. The compiler says: "Opening parenthesis without prior test name".

    What's the correct way of doing this?


  • Moderators

    You can use "contains":http://qt-project.org/doc/qt-5/qmake-test-function-reference.html#contains-variablename-value test function:
    @
    contains(DEFINES, USE_THEME_ANDROID_HOLOLIGHT) {
    RESOURCES += images/android-holo-light/android-holo-light.qrc
    }
    @



  • Apparently, contains doesn't work for defines that are set to some value (I set them to 1 or 0 in the example above), but if I remove this and simply define the constant or not, your suggestion works. Thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.