PDA

View Full Version : include "QDialog" etc not found after upgrade from 5.4 to 5.6



gig-raf
10th April 2016, 20:04
Dear all,

this is a bit stupid. I had a working environment with QT5.4 and Qtcreator. I just upgraded to QT5.6 and qtcreator to 3.1, when I now want to recompile by code I get:



fatal error: QLabel: No such file or directory
#include <QLabel>



So before this was working fine, I could compile without error, but now I need to specify



#include <QtWidgets/QLabel>


etc. My code is quite large with many includes, do I really need to specify QNetwork, QWidgets etc. for every include?? or do I have a an environment variable set wrong or missing?

I also have lots of warning such as



Makefile:1248: warning: overriding commands for target `moc_mainwindow.cpp'
Makefile:1064: warning: ignoring old commands for target `moc_mainwindow.cpp'



I run on Ubuntu,

which qmake
/opt/Qt5.6.0/5.6/gcc_64/bin/qmake

gig-raf
11th April 2016, 20:20
Does nobody have an idea, or is the problem so obvious that no-one bothers to answer :-)


I am quite sure it is some dumb mistake from my side, an include path or lib path that is not correct, but I don't see the problem.

I have removed the .pro file
do qmake -project
qmake
make


hereafter I get the error such as :

fatal error: QApplication: No such file or directory
#include <QApplication>
^
compilation terminated.



if I modify the include and specify the dir such as i.e. <QtWidgets/QLabel> and so on it does work, but it is annoying to have to do that for every lib I use.

what am I missing here?

d_stranz
11th April 2016, 20:31
In your .pro file, you should be specifying additional include paths <QT_DIR>/include, <QT_DIR>/include/QtCore, <QT_DIR>/include/QtWidgets, etc. where <QT_DIR> is the path to your Qt installation (or an environment variable that says the same thing). These might have been in your .pro file, but when you deleted it it, they were lost.

I am not sure why your configuration changed when moving from Qt 5.4 to Qt 5.6. There might have been something in your kit configuration for 5.4 (if you are using Qt Creator) which identified these subdirectories which didn't get updated when you moved.

gig-raf
11th April 2016, 20:37
Thanks mate! is it not a bad idea to update the pro file manually. I mean I work on my projects on two different computers with different setup, hence I use qmake -project every day.

I will check my qtcreator to see if I have variable pointing to the old directories.

cheers!

d_stranz
11th April 2016, 20:47
I'm not really a Qt Creator / qmake user; I work mainly in Visual Studio. There, I can specify include and library paths using environment variables: $(QTDIR)/include, etc. I would be surprised if you can't do the same thing in a .pro file. This would let you move the same project to different computers and it would work the same if you have the same environment variable on each system pointing to the correct place.

anda_skoa
11th April 2016, 22:05
In your .pro file, you should be specifying additional include paths <QT_DIR>/include, <QT_DIR>/include/QtCore, <QT_DIR>/include/QtWidgets, etc. where <QT_DIR> is the path to your Qt installation (or an environment variable that says the same thing).

That should not be necessary as qmake knows which path its Qt was installed in.

All examples so far were headers from QtWidgets, maybe the QT variable in the .pro file is missing the "widgets" module?

Cheers,
_

d_stranz
11th April 2016, 23:11
maybe the QT variable in the .pro file is missing the "widgets" module?

Yes, better solution.

gig-raf
12th April 2016, 07:08
Thanks helping out here!

I agree that putting in the QT += widgets in my pro file will partially solve the problem. But I never had to do this with the QT5.4 setup I had before.

I thought the qmake -project would detect what qt libs I need and dynamically create the pro file for me. It is quite handy and safes me lots of time when moving between my development environments (Which are not identical).

cheers!

anda_skoa
12th April 2016, 09:18
I agree that putting in the QT += widgets in my pro file will partially solve the problem. But I never had to do this with the QT5.4 setup I had before.

Than this worked by accident, qmake requires to know which modules to use for both the include paths and the libraries to link to and "widgets" is required for QtWidgets since 5.0.

Adding "widgets" is one of the things that need to be done when porting from Qt4 to Qt5, as QtWidgets was split from QtGui into its own module.



I thought the qmake -project would detect what qt libs I need and dynamically create the pro file for me.

No, I think it only detects the sources and headers.



It is quite handy and safes me lots of time when moving between my development environments (Which are not identical).

Then it might be worth considering always using the same build system or using something that can generate input for all required build systems.
E.g. qmake can not only generate Makefiles, it can also generate visual studio project files.

CMake has even more output generators.

Cheers,
_

gig-raf
12th April 2016, 19:21
Thanks guys. I can not thank you enough for the help.

You are right, I most completely starred myself blind on this problem. Of course I have to update the pro files and add in my include and QT libs manually. I was so sure that qmake -project would do that for me that I completely ruled it out.

So when I removed the pro file and setup the project again things stopped working.


...I hang my head in shame!