danicheeta danicheeta - 1 year ago 115
C++ Question

no such file or directory for .h file error in Qt after organizing project

consider that i have a main.cpp file in root which include "mainview.h" in it.
The mainview.h file is in root/View.
I have configured the .pro file(add View/mainview.h to HEADERS tag) but it still can't find mainview header in main.cpp

Answer Source

If you do e.g.

#include "mainview.h"

then the preprocessor will look first in the same directory as the source file doing the #include, then it will look in the system directories. If you have a header file in a sub-directory then you need to specify that too:

#include "View/mainview.h"