I could not find a reliable way though some say that qtchooser works but it doesn't work.
What I do as a workaround is to install
qt4 at first then install qt5, to revert back to qt4 just remove
qt5-default, it will use qt4. To switch back to
qt5 just install
qt5-default. It's a tiny deb package lower than 500kb.
When you attepted to remove qt5-default it will automatically install qt4-default
What I did yesterday to use latest version of qmake, I downloaded 32 bit offline installer from http://download.qt-project.org/official_releases/qt/5.2/5.2.1/qt-opensource-linux-x86-5.2.1.run then set executable flag and installed it to
/home/$USER/Qt5.2.1, it doesn't install it into system path. To use qmake to create makefile you need to specify the path
/home/$USER/Qt5.2.1/5.2.1/gcc/bin/qmake -Wall ../project.pro worked for me
EDIT3: I found an easier way to switch between qt4 and qt5 using environment variables
To switch to qt4
As I get experienced about programming I come across more simple solutions.
You don't need to switch between QT4 <-> QT5 at all.
Install QT4 and QT5 packages from Ubuntu repositories and then locate qmake
I am running Ubuntu 14.04.3 32 bit so my qmake paths are:
All you can do to build your project is to run
or for qt5:
in your source directory where project*.pro file exist.
Then to compile it with