Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Conditions on Qt Project not working
Forum Update on Monday, May 27th 2025

[SOLVED] Conditions on Qt Project not working

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cayan
    wrote on 2 Jul 2013, 19:18 last edited by
    #1

    Using:
    @contains(CONFIG, value)@

    implies in the same output.

    @#-------------------------------------------------

    Project created by QtCreator 2013-07-02T15:18:36

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = untitled
    TEMPLATE = app

    CONFIG += TEST1
    #CONFIG += TEST2

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui

    contains(CONFIG, TEST1)
    {
    warning(test1)
    DEFINES += TEST1
    }

    TEST2
    {
    warning(test2)
    DEFINES += TEST2
    }

    warning($$CONFIG)
    warning($$DEFINES)
    @

    qMake output:
    @16:11:43: Running steps for project untitled...
    16:11:43: Starting: "C:\Qt\5.0.2\mingw47_32\bin\qmake.exe" untitled\untitled.pro -r -spec win32-g++ "CONFIG+=debug" "CONFIG+=declarative_debug" "CONFIG+=qml_debug"
    Project WARNING: test1
    Project WARNING: test2
    Project WARNING: lex yacc debug exceptions depend_includepath testcase_targets import_plugins import_qpa_plugin rtti_off incremental_off windows qt warn_on release link_prl debug_and_release debug_and_release_target precompile_header copy_dir_files release shared rtti qpa win32 mingw gcc debug declarative_debug qml_debug TEST1
    Project WARNING: UNICODE TEST1 TEST2
    Project WARNING: test1
    Project WARNING: test2
    Project WARNING: lex yacc debug exceptions depend_includepath testcase_targets import_plugins import_qpa_plugin rtti_off incremental_off windows qt warn_on release link_prl debug_and_release debug_and_release_target precompile_header copy_dir_files release shared rtti qpa win32 mingw gcc debug declarative_debug qml_debug debug DebugBuild Debug build_pass TEST1
    Project WARNING: UNICODE TEST1 TEST2
    Project WARNING: test1
    Project WARNING: test2
    Project WARNING: lex yacc debug exceptions depend_includepath testcase_targets import_plugins import_qpa_plugin rtti_off incremental_off windows qt warn_on release link_prl debug_and_release debug_and_release_target precompile_header copy_dir_files release shared rtti qpa win32 mingw gcc debug declarative_debug qml_debug release ReleaseBuild Release build_pass TEST1
    Project WARNING: UNICODE TEST1 TEST2@

    DEFINES on Makefile.Debug:
    @DEFINES = -DUNICODE -DTEST1 -DTEST2 -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN@

    DEFINES on Makefile.Release:
    @DEFINES = -DUNICODE -DTEST1 -DTEST2 -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -DQT_NEEDS_QMAIN@

    Any ideas?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 2 Jul 2013, 20:55 last edited by
      #2

      Hi,

      You should put the { on the same line as the condition:
      @contains(CONFIG, TEST1) {
      warning(test1)
      DEFINES += TEST1
      }
      @

      Otherwise it starts a new series of instructions hence your result.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Cayan
        wrote on 2 Jul 2013, 21:51 last edited by
        #3

        It worked, thank you. I'd never thought that was the issue.

        1 Reply Last reply
        0

        1/3

        2 Jul 2013, 19:18

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved