
If you’re interested in knowing the current version of Qt that you’re using, open up a terminal and type in the command
qmake -v
Qt is something that you’ll definitely require if you’re using or more precisely developing KDE applications. Not only is the KDE SC written in Qt but most applications require different versions of Qt (If I’m not wrong, Digikam and Plasma Media Center required differing versions of Qt).
I know for sure that Plasma Media Center requires Qt4 and I also built the IDE Qt creator (which requires Qt 5.0.2 or so) from source. I was also able build Project Tox which required Qt version 5.2.0 and nothing less. So, I think it’s quite obvious that you might encounter a situation wherein you have more than one Qt version and you have to then choose between the right one. This is however a bit tricky.
To check the different versions of Qt installed on your system, type in the command
qtchooser -list-versions
. Here’s the output on my system
➜ ~ git:(master) ✗ qtchooser -list-versions qt4 qt5-x86_64-linux-gnu 5 qt5 default
I obviously had a torrid time in trying to configure the appropriate versions for different applications. I thought that using the “qtchooser” command would be enough to get this problem sorted out but unfortunately there doesn’t seem to be one solid article out in the web that describes the exact usage of the command “qtchooser” and the man page for the same doesn’t really help much in my honest opinion(IMHO).
So while looking through various articles and trying different combinations etc , I finally came across one article [1] that finally solved my issues and in the end it turned out to be quite simple. So, whenever you want to switch to a version of Qt you needn’t really fiddle with the “qtchooser” command, but you can open up a terminal and type in this
export QT_SELECT = <desired Qt version>
As mentioned earlier, you can choose the appropriate version from the output of the command “qtchooser -list-versions”. Here’s how things look like in my system after playing around with these commands.
➜ ~ git:(master) ✗ qmake -v QMake version 2.01a Using Qt version 4.8.4 in /usr/lib/x86_64-linux-gnu ➜ ~ git:(master) ✗ qtchooser -list-versions qt4 qt5-x86_64-linux-gnu 5 qt5 default ➜ ~ git:(master) ✗ export QT_SELECT = 5 zsh: bad assignment ➜ ~ git:(master) ✗ export QT_SELECT = qt5 zsh: bad assignment ➜ ~ git:(master) ✗ export QT_SELECT=qt5 ➜ ~ git:(master) ✗ qmake -v QMake version 3.0 Using Qt version 5.0.2 in /usr/lib/x86_64-linux-gnu ➜ ~ git:(master) ✗ export QT_SELECT=5 ➜ ~ git:(master) ✗ qmake -v QMake version 3.0 Using Qt version 5.0.2 in /usr/lib/x86_64-linux-gnu ➜ ~ git:(master) ✗ export QT_SELECT=qt5-x86_64-linux-gnu ➜ ~ git:(master) ✗ qmake -v QMake version 3.0 Using Qt version 5.0.2 in /usr/lib/x86_64-linux-gnu ➜ ~ git:(master) ✗ echo "returning back to the stable version --> qt4" returning back to the stable version --> qt4 ➜ ~ git:(master) ✗ export QT_SELECT=qt4 ➜ ~ git:(master) ✗ qmake -v QMake version 2.01a Using Qt version 4.8.4 in /usr/lib/x86_64-linux-gnu
and that ladies and gentleman, is how you switch between different versions of Qt !
Thank you.
[1] http://www.linuxfromscratch.org/blfs/view/7.4/general/qtchooser.html
Big thanks, it helped me resolve my problem!
“I thought that using the “qtchooser” command would be enough”. Indeed I was thinking that, thanks.
“and that ladies and gentleman, is how you switch between different versions of Qt ! Thank you”
No, Thanks to you!!! Take a bow. (User clapping hands together) I agree man qtchooser isn’t helpful at all.
Glad it worked. Though it does look like qtchooser and QT_SELECT are going to be a thing of the past. You can notice distro’s shipping Qt version specific packages, like qt5-qmake for eg.
I’m on an Archlinux these days and they’ve certainly dropped qtchooser from their packages : https://bugs.archlinux.org/task/51308
This just saved me on gentoo compiling Mame. I googled “qtchooser examples” to get here. This is exactly the missing info i needed! THANK YOU!
I updated ~/.pam_environment manually with QT_SELECT, but qtchooser didn’t recognise the setting. ‘export’ put it in the right profile; note the command is without spaces around ‘=’:
export QT_SELECT=qt5
I don’t know what the ~/.pam_environment file is meant for and I also didn’t understand how you updated it manually with QT_SELECT. Perhaps I’m misreading something ?
And yes, the spaces around ‘=’ are wrong. That is what I try to show by pasting the output of that assignment(zsh: bad assignment) 🙂