Using the `qtchooser` Command (with examples)
- Linux
- November 5, 2023
1. List available Qt versions from the configuration files:
qtchooser --list-versions
Motivation: This command is useful to know which Qt versions are available on your system. It provides a list of Qt versions that have been configured using the qtchooser
tool.
Explanation: The --list-versions
option is used to display all the available Qt versions from the configuration files. This command only lists the versions that have been registered using qtchooser
.
Example Output:
5
default
The output shows that there are two available Qt versions: ‘5’ and ‘default’.
2. Print environment information:
qtchooser --print-env
Motivation: This command allows you to check the environment variables related to Qt. It can be handy to inspect the Qt-related variables set by qtchooser
.
Explanation: The --print-env
option is used to print environment information related to Qt. It displays the current values of environment variables including QT_SELECT
, which specifies the selected Qt version.
Example Output:
QT_SELECT=5
XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
The output shows that the selected Qt version is ‘5’, and it also lists other environment variables that might be relevant.
3. Run the specified tool using the specified Qt version:
qtchooser --run-tool=tool --qt=version_name
Motivation: This command allows you to execute a specific Qt tool using a particular Qt version. It is useful when you want to run a tool with a specific version instead of the default one.
Explanation: The --run-tool
option is used to specify the tool that you want to run. The --qt
option is used to specify the Qt version to be used for running the tool.
Example:
qtchooser --run-tool=qmake --qt=5
This command runs the qmake
tool using Qt version 5.
4. Add a Qt version entry to be able to choose from:
qtchooser --install version_name path/to/qmake
Motivation: This command allows you to add a new Qt version entry so that you can choose it for running Qt tools. It is useful when you have installed a Qt version manually and want to configure it with qtchooser
.
Explanation: The --install
option is used to add a new Qt version entry. The version_name
argument specifies the name of the version to be added. The path/to/qmake
argument specifies the path to the qmake
executable for the new Qt version.
Example:
qtchooser --install 6 /usr/local/Qt6.0.0/bin/qmake
This command adds a new Qt version entry named ‘6’ with the qmake
executable located at /usr/local/Qt6.0.0/bin/qmake
.
5. Display all available options:
qtchooser --help
Motivation: This command is useful when you need to get an overview of all available options provided by the qtchooser
command. It can help you to explore and understand the various features and functionalities of qtchooser
.
Explanation: The --help
option is used to display a help message that provides an overview of all available options, their usage, and a brief description of each option.
Example Output:
Usage: qtchooser [OPTION]...
A wrapper used to select between Qt development binary versions.
--help Display this information and exit.
[...]
Report bugs at <https://bugreports.qt.io/>
The output shows the general usage information and a brief overview of the available options.
In this article, we have explored various use cases of the qtchooser
command by providing code examples, motivations, explanations, and example outputs for each use case. By understanding these examples, you can effectively utilize qtchooser
to manage and select different Qt development binary versions based on your requirements.