I have my C++ project files and want to create an additional graphical user interface for these sourcefiles. I am using windows, MVSC2012 and Qt 5.1.1 with Qt Creator 2.8.1.
So here is what i have:
My QtCreator project folder, including the following auto-generated files
c:/creatorProject/creatorProject/main.cpp
c:/creatorProject/creatorProject/mainwindow.cpp
c:/creatorProject/creatorProject/mainwindow.h
c:/creatorProject/creatorProject/mainwindow.ui
c:/creatorProject/creatorProject/creatorProject.pro
c:/creatorProject/creatorProject/creatorProject.pro.user
Furthermore I the source files with the "logic" in a separated folder, e.g.
c:/programLogic/myFunctions.h
c:/programLogic/myFunctions.cpp
So I simply want to add these files to my QtCreator project so that I can e.g. include "myFunctions.h" and work with it.
My attempt: I used Qt Creator and added myFunctions.h respectively myFunctions.cpp by using "creatorProject >> right click >> add existing file..". After doing that my creatorProject.pro looks like this:
[...]
SOURCES += main.cpp\
mainwindow.cpp \
../../programLogic/myFunctions.cpp
HEADERS += mainwindow.h \
../../programLogic/myFunctions.h
Looks totally fine for me. Qt Creator even shows these files within the project explorer! However I have trouble using myFunctions.h within mainwindow.cpp.
#include "myFunctions.h" // Include can not be found
#include "../../programLogic/myFunctions.h" // Include is found but I get linker errors since myFunctions.cpp is not compiled?!
What is wrong within my setup?
You need to add the
INCLUDEPATH
also in your.pro
file.Something like: