Project tree files with qmake contains function

  • Hi,
    i mentioned that if I add the contains function in the .pro file, where several header and source files are added, these files also are shown in the project tree in Qt Creator even if the contains function returns false.

    contains(DEFINES, MYCLASSES) {
        SOURCES += \
        HEADERS += \

    Even if MYCLASSES is not defined, the files myclass.h and myclass.cpp is still shown in the project tree. Here is a screenshot.

    If I add the message function (not shown in the screenshot), I see that the scope isentered when the MYCLASSES is defined.

    I'm using Qt Creator 4.7.2 on macOS.

    But why is Qt Creator still shown these files in the project tree?


  • Lifetime Qt Champion


    Because the project view's role is to show you what's inside your project.

    The fact that the files are shown doesn't mean that they are going to be compiled.

  • @SGaist

    Thanks, make sense!

Log in to reply

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