Managing Qt Versions
Introduction
To let Qbs know where the Qt build or Qt version is that you want to use, you must register it.
Register a Qt version like this:
qbs setup-qt /usr/bin/qmake myqt
This will create the myqt profile which can then be used on the command line:
qbs profile:myqt
Note: If the setup-toolchains command has found more than one toolchain, you will need to manually link your Qt profile to one of them, like this:
qbs config profiles.myqt.baseProfile <profile name>
Manual Setup
Everything that the setup-qt tool does can be done manually, as described in this section.
Here is an example for registering Qt, installed on Ubuntu GNU/Linux, again using a profile called myqt:
qbs config profiles.myqt.Qt.core.binPath /usr/bin qbs config profiles.myqt.Qt.core.incPath /usr/include/qt4 qbs config profiles.myqt.Qt.core.libPath /usr/lib/x86_64-linux-gnu qbs config profiles.myqt.Qt.core.mkspecPath /usr/share/qt4/mkspecs/linux-g++ qbs config profiles.myqt.Qt.core.version 5.1.0
Multiple Qt Builds
To support multiple Qt builds, or in fact any combination of related settings, you need to create several profiles. The following example illustrates how to set up three different profiles, each for a different Qt build:
qbs setup-qt ~/dev/qt/4.7/bin/qmake qt47 qbs setup-qt ~/dev/qt/4.8/bin/qmake qt48 qbs setup-qt ~/dev/qt/5.0/qtbase/bin/qmake qt5
You can set the default Qt build like this:
qbs config defaultProfile qt5
To choose a Qt build that is different from the default, use:
qbs build profile:qt48
You can set other properties in a profile (not just Qt ones), in the same way you override them from the command line. For example:
qbs setup-qt C:\Qt\5.0.0\qtbase\bin\qmake.exe qt5 qbs config profiles.qt5.qbs.architecture x86_64 qbs config profiles.qt5.baseProfile msvc2010
The last example uses the inheritance feature of profiles. All settings in the profile set as baseProfile are known in the derived profile as well. They can of course be overridden there.
Customized Qt Settings
If you have built your Qt with the option -qtnamespace MyNamespace then you must set the following config value:
qbs config profiles.myqt.Qt.core.namespace MyNamespace
The same goes for the -qtlibinfix option.
qbs config profiles.myqt.Qt.core.libInfix MyInfix