Adding search directory in Qt IDE



  • I would like to add a very long path directly into my Qt project, so that I don't have to write something like:

    @#include "C:\dir1\dir2\dir3\dir4\dir5\dir6\dir7\dir8\my_header.hpp"@

    Can this be done using QTIDE?

    Thanks


  • Moderators

    This has nothing to do with Qt Creator. You need to add your header to INCLUDEPATH in you .pro file (if you are using qmake):
    @
    INCLUDEPATH+=C:/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8
    @

    Then, in your source file:
    @
    #include "my_header.hpp"
    @

    On a related note, don't use absolute paths in your source code! Make them relative to your project's root directory. Otherwise your code will not be useful on other machines.


Log in to reply
 

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