Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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:

    dc24595e-17c3-4ae4-be77-c52ccb52ac82-image.png

    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 \
        ../src/windialog.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 \
        ../src/windialog.h
    
    
    FORMS += \
        ../src/besttimesdialog.ui \
        ../src/customfielddialog.ui \
        ../src/windialog.ui
    
     RESOURCES += \
        ../src/minesweeper.qrc
    

    The minefield.pro:

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

    The src.pro:

    QT += widgets
    CONFIG += c++17
    
    TARGET = src
    TEMPLATE = app
    
    include(../minefield-src.pri)
    
    SOURCES += main.cpp
    

    The tests.pro:

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

    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:

    ef089e8d-0ea3-41d6-bada-4ca24a79b670-image.png

    d1983cff-faf0-44ce-b74a-e7f9424286f5-image.png

    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

    Hi,

    You are missing

    QT += widgets
    

    In your test .pro file.



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

    6ef64b94-18d5-4b96-8567-8d6eacb10015-image.png

    //...
    #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?


  • Qt Champions 2019

    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