add
INCLUDEPATH += Header/common/tools
to .pro file and include your header simply like this
#include "abc.h"
質問
I am new with Qt and Qt Creator. I have created some sub-directories in order to separate the classes of the project. Now, I am trying to include the headers in their respective sources but unsuccesfully.
I have separated the project as follow (-> means subdir):
Headers
-> common
-> tools
abc.h
Sources
-> common
-> tools
abc.cpp
in tools directories I have abc class. In my .pro file, it shows the following:
HEADERS+= \
Headers/common/tools/abc.h
SOURCES += \
Sources/common/tools/abc.cpp
Even though I cleaned and runned again qmake, there is a problem: when I want to include "abc.h" into "abc.cpp" in this way:
abc.cpp
#include "Header/common/tools/abc.h"
Qt Creator shows this problem:
C1083: Cannot open include file: Headers/common/tools/abc.h: No such file or directory
I guess it is a problem of path which I can't find out. Can you? Thank you in advance
解決
add
INCLUDEPATH += Header/common/tools
to .pro file and include your header simply like this
#include "abc.h"
他のヒント
You need to modify the INCLUDEPATH variable to add the folder where "Header" is located. Every path in a #include
directive will be prepended by path in include path when searching for headers.
I didn't notice that the file was not in the right directory....so basic mistake! thank you all and sorry for bothering for that!
If I were you I would get a QT book. There are many of these little idiosyncrazies, and a book makes sense of it all when you read it in sequence.
I read this QT3 book, and it was the best tech-book I ever read, but it is out of date now. Here is one by the same author - I got that one too, and it is good too. Haven't read all of it.