Why need ../ to include the path in Qt5?
-
Hi,
I transplanted the source that was made with Qt4 to Qt5.
Inclusion of compilation errors had out a lot.When an attempt is made to include the file in a different folder,
You do not specify the ../ and it becomes a compile error.
It was no problem in Qt4.
Do I need something set?<Folder structure>
- sample
main.cpp- Model
SampleModel.h, SampleModel.cpp - Data
SampleData.h, SampleData.cpp
- Model
<Qt4 source code of>
/ * SampleModel.h * /
#include "Data / SampleData.h"<Qt5 source code of>
#include "Data / SampleData.h" // error
#include "../Data/SampleData.h"Use environment: Windows7 64bit, QtCreator 3.3.0, Qt5.4.0
Best regards,
- sample
-
The paths depend on what you put in INCLUDEPATH variable in .pro file.
-
I'm sorry. I do not know what to do with.
I tried to add a INCLUDEPATH, but you get an error.
Error content is below.
C1083: 'Data / SampleData.h' No such file or directory.
@#Sample.pro
QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Sample
TEMPLATE = appINCLUDEPATH +=
Data \SOURCES += main.cpp
Data/SampleData.cpp
Model/SampleModel.cppHEADERS +=
Data/SampleData.h
Model/SampleModel.hFORMS += \
@
Thank you. -
Try
@
#include "SampleData.h"
@There was no change here between Qt 4 and 5, so it really should work.
-
I solved the problem.
It was resolved by adding a $$ PWD to include path.
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Sample
TEMPLATE = appINCLUDEPATH += $$PWD
SOURCES += main.cpp
Data/SampleData.cpp
Model/SampleModel.cppHEADERS += Data/SampleData.h
Model/SampleModel.hMr. sierdzio.
Thank you tell me. -
Hm, that is unusual, but good that you've found this out. Happy coding!