Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Creator: C++ source code syntax highlight
Forum Updated to NodeBB v4.3 + New Features

Creator: C++ source code syntax highlight

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 3 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dophinehk
    wrote on last edited by
    #1

    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".

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

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

      (Z(:^

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tobias.hunger
        wrote on last edited by
        #3

        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:-)

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dophinehk
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tobias.hunger
            wrote on last edited by
            #5

            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;-)

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dophinehk
              wrote on last edited by
              #6

              ok thank you very much

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved