Important: Please read the Qt Code of Conduct -

Include path added but still not able to include files

  • I am trying to include the folder which has my include files, I am trying to add a folder in the Build environment in the QT Creator but still I am not able to include the files, Though its very less input for somebody to explain where I am going wrong,. can anybody help me

  • What are you trying to include ? Your 'own' headers or Qt ?

    You should add modules relevant to headers in your pro file. For example, if u are trying to include QSqlQuery , you should add QT += sql in pro file

  • yes my own headers which is grouped in a different folder,. I am adding that path of that folder to build environment

    INCLUDE C:/Users/Desktop/Test Workspace/Sourcecode

    under that sourcecode folder my header files are present.

    in my file if i just include a header which is present in that particular folder its not able to fetch ,. its says no such file or directory.
    however, if i give a specific path while including say

    #include "..\ Test Workspace\Sourcecode\enums.h"

    It gets included I do not want to do this way because it might go to an endless loop if enums.h includes someother file and that wont be able to search ..
    hope you get it

  • Try adding SOURCE and HEADERS in Pro file.

    And don't worry about the endless loop. Includes in the 'enums.h' might need it to work properly.

  • I included that in the pro file but still of no avail,. I am not able to find the required file.
    is there any specific way of including a folder of headers i have just added that in the INCLUDE in the build environments and added the headername in the pro file

  • Show us the contents of your .pro file, at least the INCLUDEPATH snippet.

  • @CONFIG += designer plugin debug_and_release
    CONFIG(debug, debug|release) {
    TARGET = debug_binary
    TARGET = $$qtLibraryTarget(plugind)
    } else {
    TARGET = release_binary
    TARGET = $$qtLibraryTarget(plugin)

    TEMPLATE = lib

    HEADERS = progressbar.h customplugin.h Enums.h Structs.h BaseHandler.h HandlerFactory.h
    SOURCES = progressbar.cpp customplugin.cpp
    RESOURCES = icons.qrc
    LIBS += -L.
    INCLUDEPATH += "C:\Users\998234\Desktop\CustomPlugin Workspace\AppWorkspace\Sourcecode"

    target.path = $$[QT_INSTALL_PLUGINS]/designer
    INSTALLS += target


    My pro file looks like above.

  • By adding the INCLUDEPATH I am able to include the necessary headers required for the project
    However, how should i insert an relative path there instead of

    INCLUDEPATH += "C:\Users\998234\Desktop\Custom Workspace\Custom Workspace\Customapp\Sourcecode"

    since I am new to scripting or the makefiles, I want to know where i can find the macros to be used like

    $$qtLibraryTarget or $$[QT_INSTALL_PLUGINS]

    from there i can specify the path to the required folders

  • AFAIK, you should add here in headers and sources ,ie along with @HEADERS = progressbar.h customplugin.h Enums.h Structs.h BaseHandler.h HandlerFactory.h
    SOURCES = progressbar.cpp customplugin.cpp@

  • Yes, thanks for it. I am able to include the headers now , but was only looking at the way of giving a relative path, instead of using a absolute path as i am doing in the INCLUDEPATH macro is there a way of providing that using some environment variables or something

  • Relative path should also work. And i don't know much about env vars :(
    Perhaps you'll find "here": or "there": .Research. :)

Log in to reply