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

Qt Creator Not Correctly Parsing Includes



  • I am attempting to import a non-qt project using the "Import Existing Project" dialog. The project imports fine and compiles/runs with no issue. However, every single include is highlighted in red and shows a file not found error. Additionally, "Follow Symbol Under Cursor" does not work. It seems that Qt Creator is having trouble parsing the project, but I cannot figure out how to correct the issue.


  • Lifetime Qt Champion

    Hi and welcome to the forum.
    Did it create a .pro file from "Import Existing Project" ?
    If yes, Could you show it here ?

    Im wondering if it needs some folder for the INCLUDEPATH
    like
    INCLUDEPATH = c:/msdev/include d:/stl/include
    or something like that ?
    Its hard to guess at with know idea about project structure and subfolders :)

    However, it sounds odd it compiles and runs but all includes are red.



  • @mrjj No pro file was created, but there is an .includes and a .files file. These files list all of the included directories and files respectively. I followed the instructions here and they did not mention a .pro file. I would show you the sub-folders and structure but it is a complex project.


  • Lifetime Qt Champion

    @nlfortier
    Ok, i though it would. ignore that then.
    Maybe its the code model that is acting up ?
    Could try disable it for a moment ?
    menu: Help->About Plugins then
    alt text

    and restart creator. then open and see if includes are still red.



  • @mrjj Thanks! That was helpful. I still can't use "Follow Symbol Under Cursor" on classes defined in different sub-folders, but the annoying red highlighting is gone.


  • Lifetime Qt Champion

    @nlfortier you need to properly set up the include paths in .includes and add predefined macros to .config

    Then it will work fine, probably even with Clang. I use it everyday in many projects.



  • @aha_1980 I have set up the .includes file and all directories containing the header files have been added, but the issues still persists. It cannot seem to find any included header files unless they are in the same directory as the source file.



  • I solved the issue. It turns out that I needed to add the absolute path for the root project directory to the includes file. Once I did, everything worked great.


  • Lifetime Qt Champion

    @nlfortier ah, yes! I think you dont need the full path, but add a line with . which means current directory.

    a bit annoying, but it works...


Log in to reply