Qt World Summit: Submit your Presentation

Header files in a different directory problem

  • I inherited a project with .cpp files in /src and .h files in /include

    I added INCLUDEPATH="include" and now the project compiles.

    However, I can not switch between header source with F4. Does this feature only work if the header file is in the same folder as the source file? (Any way around this? I hate to have to merge them all into one folder)

  • Lifetime Qt Champion


    AFAIK it should also work like that. Which version of Qt Creator are you using ?

    In between you can try using

    @INCLUDEPATH += $$PWD/include@

  • I'm using the latest Qt Creator (as part of the 5.1.1 package) direct from the qt-project site. I tried the INCLUDEPATH as you suggested but it won't work.

    I can only switch between header and source using F4 if the .h and .cpp are in the same directory. Can you confirm you are able to use different directories and switch?

  • Hi just a note, (i'm a newbe) don't know for sure it'll work but
    Also note the '+' sign left och '='
    try '/' ahead of "include"

    for ex.
    INCLUDEPATH += "/include" \

    or what ever path it is to your include


  • Lifetime Qt Champion

    Good catch, I didn't saw the missing +

    Indeed, it must be there otherwise the content of INCLUDEPATH is replaced

Log in to reply