Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I feel like there should be a simple way of doing this, but my googlefu is failing so I'd really appreciate some info on how to switch (or even permanently change) which version of Qt is used when doing qmake. If I ask which version I get the following:

~ $ qmake --version
QMake version 3.0
Using Qt version 5.0.1 in /usr/lib/x86_64-linux-gnu

I've install QtCreator, but I'm not sure where to go from here.

share|improve this question
up vote 5 down vote accepted

This isn't necessarily Unix/Linux specific, so you are probably better asking this on Stack Overflow. Never the less, QtCreator is usually quite good at detecting alternative Qt installs, just create a new project and look under the Projects tab on the left. You can set different build configurations there. There should be a drop down box to select from the various installed versions for each configuration.

Otherwise, it seems to the QTDIR environmental variable is used to set the Qt version. By default QtCreator sets this to /usr/share/qt4 for me, so setting it to the equivalent path (ie the one where the configuration files are) should make qmake build with a different version. You could test with something like:

QTDIR=/usr/share/qtX qmake --version

It may also be possible to set this in the .pro file, but if so it is undocumented (as with quite a lot of qmake variables).

Also, if you want to build with a specific major version, qmake is usually just symlinked to a binary for the default major version. The real binaries are qmake-qt4, qmake-qt5 etc. Also see man qtchooser and the qtX-default packages on Debian based systems.


There is a bug with qtchooser on Ubuntu 13.04 and 13.10 which seem to affect the way Qt applications detect different Qt versions, see https://bugs.launchpad.net/ubuntu/+source/qt4-x11/+bug/1177823. This may affect QtCreator also.

share|improve this answer
Thanks! I needed to use qmake-qt4 instead of the bald qmake - so easy, but I just couldn't find the info I needed. Thanks! – Tamsyn Michael Feb 22 '14 at 4:03
@TamsynMichael - Yes, on the linux side qmake in bin is just a symlink. So, if you used something like update-alternatives to switch back and forth, that might be ideal. It's not in update-alternatives, and things like the PyQt build scripts want a direct reference to the binary anyway - not a symlink. – RobotHumans Jan 27 '15 at 7:36

It helped me to use -qt=qt5 switch or QT_SELECT=qt5 environment variable.

qmake --version
QMake version 2.01a
Using Qt version 4.8.7 in /usr/lib/x86_64-linux-gnu

qmake -qt=qt5 --version
QMake version 3.0
Using Qt version 5.5.1 in /usr/lib/x86_64-linux-gnu

QT_SELECT=qt5 qmake --version
QMake version 3.0
Using Qt version 5.5.1 in /usr/lib/x86_64-linux-gnu
share|improve this answer

In (my) default setup on Fedora 23 having both qt-3.3.8 and qt-4.8.5 environments it was also necessary to add the /usr/libxx/qt4/bin/ directory temporarily to the PATH to allow the cmake/qmake packages to find the right version. This was necessary when building the code, not when running the finished QT4 app.

For some reason the QT3 path already was installed there permanently and unfortunately at the start of the PATH, which prevented the QT version selector working properly.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.