⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

SubDirs Project Widget not found on compilation

  • I try to convert a project into a subdirs project to add unit tests.

    My structure looks like this:


    The minefield-src.pri looks like this:

    SOURCES += \
        ../src/besttimesdialog.cpp \
        ../src/cell.cpp \
        ../src/cellinputhandler.cpp \
        ../src/converttograyscale.cpp \
        ../src/customfielddialog.cpp \
        ../src/game.cpp \
        ../src/gamesettings.cpp \
        ../src/lcddisplay.cpp \
        ../src/mainwindow.cpp \
        ../src/minefield.cpp \
        ../src/smileypushbutton.cpp \
    HEADERS += \
        ../src/besttimesdialog.h \
        ../src/cell.h \
        ../src/cellinputhandler.h \
        ../src/converttograyscale.h \
        ../src/customfielddialog.h \
        ../src/game.h \
        ../src/gamesettings.h \
        ../src/lcddisplay.h \
        ../src/mainwindow.h \
        ../src/minefield.h \
        ../src/smileypushbutton.h \
    FORMS += \
        ../src/besttimesdialog.ui \
        ../src/customfielddialog.ui \
     RESOURCES += \

    The minefield.pro:

    TEMPLATE = subdirs
    SUBDIRS += \
        src \
    OTHER_FILES = minefield-src.pri

    The src.pro:

    QT += widgets
    CONFIG += c++17
    TARGET = src
    TEMPLATE = app
    SOURCES += main.cpp

    The tests.pro:

    QT += testlib
    QT += gui
    CONFIG += C++17 console
    TEMPLATE = app
    include (../minefield-src.pri)
    APP_PATH = ../src

    First of all i see all the source files from the pri which should be a good sign.

    But when i compile i get errors like this:



    I wonder whats the Issue here? `widgets``is set in the pro files of the subprojects.

    The code successfully compiled before before I rearranged to have the project in a subdirs project with a test project

  • Lifetime Qt Champion


    You are missing

    QT += widgets

    In your test .pro file.

  • After adding it the error is solved. However now I get this Issue:


    #include <algorithm>
    void LcdDisplay::setDisplayValue(int value)
        constexpr auto minDisplayValue = -99;
        constexpr auto maxDisplayValue = 999;
        mValue = std::clamp(value, minDisplayValue, maxDisplayValue);

    This is very weired. If you look at the post above i say in both the pro files c++17. So whats the issue here?

  • Lifetime Qt Champion

    As you can see there is no compiler flag to use c++17 so your config line is wrong - I would guess it's 'c++17', not 'C++17'.

  • you are right sometime you don't see the forest because there are to many trees ;/

  • @sandro4912 is your issue solved? if so please don't forget to mark your post as such! Thanks

Log in to reply