Creator: C++ source code syntax highlight



  • Hi,

    I just upgrade QT 5.0.1 to 5.1. However, I found the source file (.cpp) are not highlighted. After further investigation, I found the #include statement is required to point to the exact path. For example, the directory looks like:
    project root.

    |-- inc
    |-- aa.h

      |-- bb.h
    

    |-- src
    |-- aa.cpp

      |-- bb.cpp
    

    qt project file
    TEMPLATE = app
    CONFIG += console
    CONFIG -= app_bundle
    CONFIG -= qt

    SOURCES +=
    src/aa.cpp
    src/bb.cpp

    HEADERS +=
    inc/aa.h
    inc/bb.h

    The include statement need to be "#include <inc/aa.h>" so that bb.cpp is highlighted. But for previous version, "#include <aa.h>" is fine.

    For previous version, I just add existing file. Then the source file is highlighted.
    For 5.1, I tried to open existing qt project file that there is no highlight.
    So I tried create a new project and add existing files. However, the result is the same.

    So my question is how I can still just include the header file only without the path".


  • Moderators

    Use this in your pro file:
    @
    INCLUDEPATH += inc
    @


  • Moderators

    Creator's code model uses the INCLUDEPATH set in your .pro file (or whatever other build system you use;-). If that is that wrongly, then the highlighting will also fail.

    In that case a build should also fail:-)



  • It works. Thanks all. Btw, If I want to include another directory, I still need to manually edit INCLUDEPATH in the project file, right? Can it be done in creator IDE?


  • Moderators

    No, creator does not have a UI for that. The build systems are so complex that any UI will work in 90% of the cases and then fail horribly for the rest. From my experience users will then avoid the UI because it "always" fails for them.

    You are a developer, I am sure you can deal with text files;-)



  • ok thank you very much


Log in to reply
 

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