I'm new to Qt and have just installed the latest version of Linux (mint Ubuntu 13.04) to begin my programming. To begin with I have installed Qt4 using the github BuildScript (this also installs QtCreater, QtDesigner, QtAssistant, and QtLinguist). I have also installed PySide, as I plan to do a little Python gui programming as well. I did not consciously install qt5, but it appears, at some point along the line I did.
The following program from the QT tutorial illustrates my issue:
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt!");
label->show();
delete label;
return app.exec();
}
Now running:
..] $ qmake -project
..] $ qmake
..] $ make
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_GUI_LIB
-DQT_CORE_LIB -I/usr/share/qt5/mkspecs/linux-g++-64 -I. -I.
-I/usr/include/qt5 -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I.
-o helloWorld.o helloWorld.cpp helloWorld.cpp:1:24:
fatal error: QApplication: No such file or directory compilation terminated.
which obviously means gcc isn't finding QApplications in the libraries specified by qmake. Investigating this:
..] $ sudo find / -name QApplication*
/usr/include/qt4/QtGui/QApplication
/usr/include/qt5/QtWidgets/QApplication
/home/drk/Canopy/appdata/canopy-1.0.1.1189.rh5-x86_64/include/QtGui/QApplication
Looking in the make file, the libraries supplied are (as can be seen from the compiler line):
INCPATH = -I/usr/share/qt5/mkspecs/linux-g++-64 -I. -I. -I/usr/include/qt5
-I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I.
Finally, looking at qmake:
..] $ qmake --version
QMake version 3.0
Using Qt version 5.0.1 in /usr/lib/x86_64-linux-gnu
So as you can see, qmake is assuming qt 5.0.1 despite the fact that I installed Qt4 and in my qt5 library directory hierarchy "QApplications" is located in /usr/include/qt5/QtWidgets and not in QtGui. However, qmake does not add QtWidgets/ to my include libraries.
I don't understand what has happened...can one not have qt4 and qt5 on one system at the same time?...does my qt5/qt5 installation appear corrupted?...how do I get qmake to use Qt4? Any suggestions would be greatly appreciated.