Get and Install Qt with Command Line Interface

From Qt Online Installer and Maintenance Tool 4.0 onward, an improved command line interface (CLI) enables installing, uninstalling, updating, and searching components. You can use the command line interface with Qt Online installer and Maintenance Tool.

The command line interface supports both interactive and non-interactive usage (unattended usage). The following topics provide examples and information on how you can use the command line interface:

Installing Without User Interaction

By default, Qt Online installer or Maintenance Tool may ask for additional information during installation, which requires user attention. Unattended usage via the command line interface is possible by providing all the requested information beforehand with appropriate options.

New Installation with Qt Online Installer

You can do new installations from the command line interface without user interaction as follows:

  1. Define the Qt Online Installer executable.
  2. Define the installation directory with --root.
  3. Use the install <list of packages> command with options for unattended usage. See the full list of options in Options for Unattended Usage.

The following examples demonstrate how you install Qt 6.5.0 binaries with Qt Online installer for Windows, macOS, and Linux. The unattended commands automatically accept the licenses (--accept-licenses), answer all message queries with their default answer (--default-answer), skip asking for permission to continue performing (--confirm-command), and accept all message queries (accept-messages):

# Windows: new installation with Qt Online installer
qt-unified-windows-x64-[Qt Online Installer version]-online.exe --root C:\Users\[username]\installation_dir --accept-licenses --default-answer --confirm-command --accept-messages install qt.qt6.650.win64_msvc2019_64

# macOS: new installation with Qt Online installer
qt-unified-macOS-x64-[Qt Online Installer version]-online.dmg --root /home/<username>/installation_dir --accept-licenses --default-answer --confirm-command --accept-messages install qt.qt6.650.clang_644

# linux: new installation with Qt Online installer
qt-unified-linux-x64-[Qt Online Installer version]-online.run --root /home/<username>/installation_dir --accept-licenses --default-answer --confirm-command --accept-messages install qt.qt6.650.gcc_64

Options for Unattended Usage lists all available options for unattended usage.

Updating Installation with Maintenance Tool

You can update existing installation from the command line interface without user interaction as follows:

  1. Define the Maintenance Tool executable.
  2. Use install <list of packages> with options for unattended usage. See the full list of options in Options for Unattended Usage.

The following examples demonstrate how you add Qt 6.5.0 binaries with Maintenance Tool to an exsting installation on Windows, macOS, and Linux. The unattended commands automatically accept the licenses (--accept-licenses), answer all message queries with their default answer (--default-answer), skip asking for permission to continue performing (--confirm-command), and accept all message queries accept-messages):

# Windows: update installation with Maintenance Tool
MaintenanceTool.exe --accept-licenses --default-answer --confirm-command --accept-messages install qt.qt6.650.win64_msvc2019_64

# macOS: update installation with Maintenance Tool
MaintenanceTool.dmg --accept-licenses --default-answer --confirm-command --accept-messages install qt.qt6.650.clang_64

# linux: update installation with Maintenance Tool
MaintenanceTool.run --accept-licenses --default-answer --confirm-command --accept-messages install qt.qt6.650.gcc_64

Options for Unattended Usage

The following table lists all options for unattended command line usage:

Option for unattended usageDescription
--accept-licensesAutomatically accepts all license agreements.
--accept-obligationsIn the opensource installations, accepts Qt Open Source usage obligations without user input.
--default-answerAnswers all message queries with their default answer.
--auto-answer <identifier=value>In case you want different answers to certain queries, you can use this option. For example, --auto-answer telemetry-question=Yes,AssociateCommonFiletypes=Yes. See all message identifiers in Message Identifiers for --auto-answer.
--accept-messagesAccepts all message queries.
--reject-messagesRejects all message queries.
--confirm-commandBy default, Qt Online Installer and Maintenance Tool print a summary of components to be affected by the option. Then they ask for permission to continue acting, to prevent accidental changes. This option skips asking for permission to continue.
--email <your_email>Provides the email when you log in from the command line. For more information, see Providing Login Information.
--pw <your_pw>Provides the password when you log in from the command line. For more information, see Providing Login Information.
--file-query <identifier=value>Sometimes the installer asks for a file or a folder location. You can provide the location with --file-query <identifier=value>. For example, --file-query PathForSDP7=<path_to_sdp>.

The identifiers are printed into the command line before the actual question and message type. You can pick up the identifiers from there.

Message Identifiers for --auto-answer

Use the --auto-answer option to provide answers to certain queries. The following table lists known identifiers and values used for --auto-answer:

IDValuesDefault
OperationDoesNotExistErrorAbort, IgnoreIgnore
OverwriteTargetDirectoryYes, NoNo
stopProcessesForUpdatesRetry, Ignore, CancelCancel
installationErrorWithCancelRetry, Ignore, CancelCancel
installationErrorWithIgnoreRetry, IgnoreIgnore
AssociateCommonFiletypesYes, NoYes
telemetry-questionYes, NoYes

Providing Login Information

Qt Online Installer and MaintenanceTool have a forced login. The forced login uses information on the qtaccount.ini file if it is available in cache. You find qtaccount.ini as follows:

Hostqtaccount.ini location
WindowsC:\Users\<username>\AppData\Roaming\Qt
macOS/Users/<username>/Library/Application Support/Qt/qtaccount.ini
Linux/home/<username>/.local/share/Qt/qtaccount.ini

Optionally, you can login either from the command line using the switches for email and password: --email <your_email> and --pw <your_pw>.

Alternatively, you can save the jwt token to the environment variable QT_INSTALLER_JWT_TOKEN. You find the token in the qtaccount.ini file.

Installing With User Interaction

You can use the command line interface with user interaction as follows:

  1. Define the executable:
    • Qt Online Installer if you need to do a new installation.
    • Maintenance Tool if you need to update an existing installation.
  2. When you do a new installation, define the installation directory with --root
  3. Use install <list of packages> to install the listed packages.

The following examples demonstrate how you create a new installation of Qt 6.5.0 binaries with Qt Online installer for Windows, macOS, and Linux:

# Windows: new installation with user interaction
qt-unified-windows-x64-[Qt Online Installer version]-online.exe --root C:\Users\[username]\installation_dir install qt.qt6.650.win64_msvc2019_64

# macOS: new installation with user interaction
qt-unified-macOS-x64-[Qt Online Installer version]-online.dmg --root /home/<username>/installation_dir install qt.qt6.650.clang_64

# linux: new installation with user interaction
qt-unified-linux-x64-[Qt Online Installer version]-online.run --root /home/<username>/installation_dir install qt.qt6.650.gcc_64

The following examples demonstrate how you update your existing installation by installing the Qt 6.5.0 binaries with Maintenance Tool:

# Windows: update installation with Maintenance Tool
MaintenanceTool.exe install qt.qt6.650.win64_msvc2019_64

# macOS: update installation with Maintenance Tool
MaintenanceTool.dmg install qt.qt6.650.clang_64

# Linux: update installation with Maintenance Tool
MaintenanceTool.run install qt.qt6.650.gcc_64

Uninstalling Packages

The command line interface provides two commands for uninstalling packages:

  • The remove <list of packages> command uninstalls the listed packages.
  • The purge command uninstalls all installed packages.

You should use both commands with Maintenance Tool.

By default, Maintenance Tool prints a summary of components to be affected by the command. Then the tool asks for permission to continue acting, to prevent accidental changes. Use --confirm-command to skip asking for permission to continue.

The following example uninstalls the Qt 6.5.0 binaries without user interaction:

# windows
MaintenanceTool.exe --confirm-command remove qt.qt6.650.win64_msvc2019_64

# macOS
MaintenanceTool.dmg --confirm-command remove install qt.qt6.650.clang_64

# linux
MaintenanceTool.run --confirm-command remove qt.qt6.650.gcc_64

The following examples uninstall all packages and ask for permission to continue performing the action:

# Windows
MaintenanceTool.exe purge

# macOS
MaintenanceTool.dmg purge

# Linux
MaintenanceTool.run purge

Searching Packages

Search available packages with the search command and regular expressions: search <regexp>. You can filter the results with --filter-packages <regexp>. For example, filtering with the display name information can help search.

For example, the following command finds all MSVC 2019 packages for Qt 6.5.0:

search .*650.*msvc2019

You get the same result when you filter the search result as follows:

search --filter-packages DisplayName=MSVC 2019,Version=6.5.0

As a result, you get the following packages:

<availablepackages>
    <package name="qt.qt6.650.win64_msvc2019_64" displayname="MSVC 2019 64-bit" version="6.5.0-0-202303290841"/>
    <package name="qt.qt6.650.win64_msvc2019_arm64" displayname="MSVC 2019 ARM64 (TP)" version="6.5.0-0-202303290841"/>
</availablepackages>

You can also use filtering when you search all Qt versions that some package is provided for. For example, search all Qt Charts packages provided for Qt versions:

search --filter-packages DisplayName=charts

The search result is as follows:

<availablepackages>
    <package name="qt.qt5.5125.qtcharts" displayname="Qt Charts" version="5.12.5-0-201909090651"/>
    <package name="qt.qt6.641.addons.qtcharts" displayname="Qt Charts" version="6.4.1-0-202211101525"/>
    <package name="qt.qt5.5123.qtcharts" displayname="Qt Charts" version="5.12.3-0-201904161619"/>

Listing Installed Packages

The list command lists all packages you have installed. Use the command with Maintenance Tool as follows:

# Windows
MaintenanceTool.exe list

# macOS
MaintenanceTool.dmg list

# Linux
MaintenanceTool.run list

Checking Updates

The check-updates command checks the updates that are available for the installed packages. Use the command with Maintenance Tool as follows:

# Windows
MaintenanceTool.exe check-updates

# macOS
MaintenanceTool.dmg check-updates

# Linux
MaintenanceTool.run check-updates

Updating Packages

The update command updates the installed packages. Use the command with Maintenance Tool as follows:

# windows
MaintenanceTool.exe update

# macOS
MaintenanceTool.dmg update

# linux
MaintenanceTool.run update

Use the command <installer_executable> --help to study the available commands and options. Popular commands are as follows:

CommandUsage
in, install <pkg ...>Installs packages given as an argument. If you don't give any packages, installs the default package set.
rm, remove <pkg ...>Uninstalls selected packages and their child components.
ch, check-updatesShows information about available updates on Maintenance Tool.
up, update <pkg ...>Updates packages given as an argument. If no packages are given, install all available updates.
se, search <regexp>Searches available packages. If you don't give any search pattern, shows all available packages. You can use the --filter-packages option to specify additional filters for the search operation. See Summary of Options in Qt Installer Framework Manual.

Qt Installer Framework Manual provides more information about the commands and options.

Selecting Mirror for Opensource

The Qt Online Installer has an option for selecting a mirror for opensource metadata and downloads. Set the mirror from the command line with the --mirror option.

For example, use --mirror as follows:

installer(.exe) --mirror http://www.nic.funet.fi/pub/mirrors/download.qt-project.org
installer(.exe) --mirror http://ftp2.nluug.nl/languages/qt
maintenancetool(.exe) --mirror http://qt.mirror.constant.com

As the example shows, don't use the full path but use the path before '/online' (no forward slash at the end).

You find the available mirrors from https://download.qt.io/online/qtsdkrepository/windows_x86/root/qt/Updates.xml.mirrorlist.

Further Information

Qt Installer Framework Manual provides more detailed information about the command line interface:

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.