There is a better method.
If you want to make your changes permanent, you need to modify the
/usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf file, which is a symlink to
Here is an example for my system (Ubuntu 17.10 x64, Qt 5.10.1). I would suggest to keep both original symlink file and its target in place (in case you want to recover the original configuration). And also create the new files in the default locations (for consistency). So here are the steps:
Rename the symlink file:
sudo mv /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf_orig
Create a new target configuration file (with any name):
gksudo gedit /usr/share/qtchooser/my_Qt_5.10.1_Desktop_gcc_x64.conf
This file must contain two lines: the first line is the path to the Qt binaries (including qmake) and the second is the path to the Qt libraries (including .so files). In my case it is
Save it and close it. Create a symlink
default.conf to the new configuration file:
ln -s /usr/share/qtchooser/my_Qt_5.10.1_Destop_gcc_x64.conf /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf
Check your Qt version:
Now it should always use the specified version.