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

    Hi,

    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" \
    "../proj2-root/include2"

    or what ever path it is to your include
    proj-root
    /src
    /include

    proj2-root
    /include2


  • 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
 

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