スタートアップガイド
aqt
は、Qt、モジュール、Qtに関連するツール、ソース、ドキュメント、サンプルなどをインストールするためのツールで、https://download.qt.io/ から入手できます。aqt
を実行する前に、何をインストールしたいのかを正確に aqt
に指示する必要があります。このセクションでは、どのようなパッケージが aqt
に用意されているのかを調べ、何をインストールしたいのかを aqt
に指示できるようにするための手順を説明します。
すべての aqt
サブコマンドには --help
オプションがあります。なにか疑問が発生した場合は、このオプションを使用してください!
Qtをインストールする
``aqt``の一般的な使い方は以下のようになります:
aqt install-qt <host> <target> (<Qt version> | <spec>) [<arch>]
pipと一緒に``aqt``をインストールしている場合は、コマンドスクリプト``aqt``で実行することができますが、場合によっては``python-m aqt``として実行する必要があるかもしれません。古いオペレーティングシステムでは、``python3-m aqt``のようにPythonバージョン3を指定する必要があるかもしれません。
Qtをインストールするには、aqt
に次の4つのことを伝える必要があります。
ホストオペレーティングシステム(Windows、Mac、Linux)
ターゲットSDK(デスクトップ、android、ios、winrt)
インストールしたいQtのバージョン
ターゲット・アーキテクチャ
Qt for IOSはMac OSでのみ利用可能であり、Qt for WinRTはWindowsでのみ利用可能であることに注意してください。
利用可能なQtのバージョンを調べるには、 aqt list-qt command を使うことができます。このコマンドはWindowsデスクトップで利用可能なQtのすべてのバージョンを出力します:
$ aqt list-qt windows desktop
5.9.0 5.9.1 5.9.2 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9
5.10.0 5.10.1
5.11.0 5.11.1 5.11.2 5.11.3
5.12.0 5.12.1 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.12.7 5.12.8 5.12.9 5.12.10 5.12.11
5.13.0 5.13.1 5.13.2
5.14.0 5.14.1 5.14.2
5.15.0 5.15.1 5.15.2
6.0.0 6.0.1 6.0.2 6.0.3 6.0.4
6.1.0 6.1.1 6.1.2
6.2.0
バージョン番号がソートされ、マイナーバージョン番号でグループ化され、1つのスペース文字で区切られていることに注意してください。すべての aqt list-qt コマンドの出力は、 aqt list-qt の出力を消費するプログラムを作成しやすくするためのものです。
aqt list-qt コマンドは https://download.qt.io/ にあるQtダウンロードリポジトリに直接問い合わせますので、このコマンドの結果は常に正確になります。Available Qt versions wikiページは過去のある時点での更新ですので、最新であるかどうかは保障されません。
使用可能なQtのバージョンがわかったので、バージョン6.2.0を選択します。
次にすべきことは、Qt 6.2.0 for Windows Desktopで利用可能なアーキテクチャを見つけることです。これを行うには、aqt list-qt に --arch
フラグを付けて確認します:
$ aqt list-qt windows desktop --arch 6.2.0
win64_mingw81 win64_msvc2019_64 win64_msvc2019_arm64 wasm_32
これは Available Qt versions wikiページにリストされているアーキテクチャの非常に小さなサブセットであることに注意してください。このリストにないアーキテクチャを使用する必要がある場合は、Available Qt versions wikiページを使用して、どのバージョンが希望するアーキテクチャをサポートしているかの大まかなアイデアを得てから、 aqt list-qt を使用して、アーキテクチャが使用可能であることを確認します。
Let's say that we want to install Qt 6.2.0 with architecture win64_mingw81
.
The installation command we need is:
$ aqt install-qt windows desktop 6.2.0 win64_mingw81
Qt 6.2の次のバージョンが利用可能になったらすぐにインストールしたいとしましょう。これを行うには、明示的なバージョンではなく SimpleSpec を使用します。
$ aqt install-qt windows desktop 6.2 win64_mingw81
7-Zip 解凍 外部 コマンド
デフォルトでは、aqt
はQtリポジトリに保存されている 7-zipアーカイブを、 aqt
と一緒にインストールされている py7zr を使って抽出します。代わりに、 -E
または --external
フラグを使って7-zipコマンドパスを指定することもできます。例えば、Windowsデスクトップで次のコマンドを使って 7-zip を使うことができます。
C:\> aqt install-qt windows desktop 6.2.0 gcc_64 --external 7za.exe
Linuxでは、次のコマンドを使用して p7zip (Linuxに移植された 7-zip )を指定できます。これはデフォルトでインストールされることが多い 7-zip です。
$ aqt install-qt linux desktop 6.2.0 gcc_64 --external 7z
出力ディレクトリの変更
By default, aqt
will install all of the Qt packages into the current
working directory, in the subdirectory ./<Qt version>/<arch>/
.
For example, if we install Qt 6.2.0 for Windows desktop with arch win64_mingw81
,
it would end up in ./6.2.0/win64_mingw81
.
別の場所にインストールしたい場合は、-O
または --outputdir
フラグを使う必要があります。このオプションは、aqt install-
で始まる他のすべてのサブコマンドにも使えます。
純正のGUIインストーラが使うデフォルトのディレクトリである C:\Qt
にインストールするには、以下のコマンドを使います:
C:\> mkdir Qt
C:\> aqt install-qt --outputdir c:\Qt windows desktop 6.2.0 win64_mingw81
モジュールのインストール
Qt 5.15.2用のモジュールをWindows デスクトップにインストールする必要があるとします。まず、モジュールが何と呼ばれているかを調べる必要があります。そのためには aqt list-qt と --modules
フラグを使用します。Qtの各バージョンには、ホストOS/ターゲットSDK/アーキテクチャの組み合わせごとに異なるモジュールリストがあるので、その情報を aqt list-qt に提供する必要があります:
$ aqt list-qt windows desktop --modules 5.15.2 win64_mingw81
qtcharts qtdatavis3d qtlottie qtnetworkauth qtpurchasing qtquick3d
qtquicktimeline qtscript qtvirtualkeyboard qtwebengine qtwebglplugin
これらのモジュールをインストールする前に、これらのモジュールについてもっと知りたいとしましょう。そのためには --long-modules
フラグを使うことができます:
$ aqt list-qt windows desktop --long-modules 5.15.2 win64_mingw81
Module Name Display Name
======================================================================
debug_info Desktop MinGW 8.1.0 64-bit Debug Information Files
qtcharts Qt Charts for MinGW 8.1.0 64-bit
qtdatavis3d Qt Data Visualization for MinGW 8.1.0 64-bit
qtlottie Qt Lottie Animation for MinGW 8.1.0 64-bit
qtnetworkauth Qt Network Authorization for MinGW 8.1.0 64-bit
qtpurchasing Qt Purchasing for MinGW 8.1.0 64-bit
qtquick3d Qt Quick 3D for MinGW 8.1.0 64-bit
qtquicktimeline Qt Quick Timeline for MinGW 8.1.0 64-bit
qtscript Qt Script for MinGW 8.1.0 64-bit
qtvirtualkeyboard Qt Virtual Keyboard for MinGW 8.1.0 64-bit
qtwebglplugin Qt WebGL Streaming Plugin for MinGW 8.1.0 64-bit
Note that if your terminal is wider than 95 characters, this command will show
release dates and sizes in extra columns to the right.
If you try this, you will notice that debug_info
is 5.9 gigabytes installed.
Also, notice that the 'Display Name' indicates which compiler the module is
intended to be used with. In this case, for the architecture win64_mingw81
,
you will most likely want to use the "MinGW 8.1.0 64-bit" compiler.
Here's what the command prints when you use it with the ambiguously-named
win64_mingw
architecture:
$ python -m aqt list-qt windows desktop --long-modules 6.2.4 win64_mingw
Module Name Display Name
=======================================================================
debug_info Desktop MinGW 11.2.0 64-bit debug information files
qt3d Qt 3D for MinGW 11.2.0 64-bit
qt5compat Qt 5 Compatibility Module for MinGW 11.2.0 64-bit
qtactiveqt Qt 3D for MinGW 11.2.0 64-bit
qtcharts Qt Charts for MinGW 11.2.0 64-bit
...
You can find out how to install MinGW 8.1.0 and 11.2.0 in the Installing Tools section.
Let's say that we want to install qtcharts
and qtnetworkauth
.
We can do that by using the -m
flag with the aqt install-qt command.
This flag receives the name of at least one module as an argument:
$ aqt install-qt windows desktop 5.15.2 win64_mingw81 -m qtcharts qtnetworkauth
利用可能なすべてのモジュールをインストールしたい場合は、all
キーワードでインストールできます。
$ aqt install-qt windows desktop 5.15.2 win64_mingw81 -m all
aqt list-qt コマンドは、スクリプト化できるように意図して作られていることを覚えていますか?Qt 5.15.2で利用可能なすべてのモジュールをインストールする1つの方法は aqt list-qt の出力を aqt install-qt に以下のように送ることです:
$ aqt install-qt windows desktop 5.15.2 win64_mingw81 \
-m $(aqt list-qt windows desktop --modules 5.15.2 win64_mingw81)
このコマンドを実行するにはUnixスタイルのシェルが必要ですし、Windowsでは少なくともgit-bashが必要です。この xargs
に相当するコマンドは、読者の練習課題です。
If you want to install all available modules, you are probably better off using
the all
keyword, as discussed above. This scripting example is presented to
give you a sense of how to accomplish something more complicated.
Perhaps you want to install all modules except qtnetworkauth
; you could write a script
that removes qtnetworkauth
from the output of aqt list-qt,
and pipe that into aqt install-qt.
This exercise is left to the reader.
Android用Qtのインストール
Let's install Qt for Android. This will be similar to installing Qt for Desktop on Windows.
注釈
Versions of aqtinstall older than 3.1.0 required the use of the --extensions
and
--extension
flag to list any architectures, modules, or archives for Qt 6 and above.
These flags are no longer necessary, so please do not use them.
$ aqt list-qt windows android # Print Qt versions available
5.9.0 5.9.1 ...
...
6.4.0
$ aqt list-qt windows android --arch 6.2.4 # Print architectures available
android_x86_64 android_armv7 android_x86 android_arm64_v8a
$ aqt list-qt windows android --modules 6.2.4 android_armv7 # Print modules available
qt3d qt5compat qtcharts qtconnectivity qtdatavis3d ...
$ aqt install-qt windows android 6.2.4 android_armv7 -m qtcharts qtnetworkauth # Install
Please note that when you install Qt6 for android or ios, the installation will not
be functional unless you install the corresponding desktop version of Qt alongside it.
You can do this automatically with the --autodesktop
flag:
$ aqt install-qt linux android 6.2.4 android_armv7 -m qtcharts qtnetworkauth --autodesktop
WASM用Qtのインストール
To find out how to install Qt for WASM, we will need to use the wasm_32
architecture.
We can find out whether or not that architecture is available for our version of Qt with the
--arch
flag.
$ python -m aqt list-qt windows desktop --arch 6.1.3
win64_mingw81 win64_msvc2019_64
$ python -m aqt list-qt windows desktop --arch 6.2.0
win64_mingw81 win64_msvc2019_64 win64_msvc2019_arm64 wasm_32
Not every version of Qt supports WASM. This command shows us that we cannot use WASM with Qt 6.1.3.
Please note that the WASM architecture for Qt 6.5.0+ changed from wasm_32
to wasm_singlethread
and
wasm_multithread
. Always use aqt list-qt
to check what architectures are available for the desired version of Qt.
We can check the modules available as before:
$ aqt list-qt windows desktop --modules 5.15.2 wasm_32 # available modules
qtcharts qtdatavis3d qtlottie qtnetworkauth qtpurchasing qtquicktimeline qtscript
qtvirtualkeyboard qtwebglplugin
以前と同じようにQt for WASMをインストールできます。
$ aqt install-qt windows desktop 5.15.2 wasm_32 -m qtcharts qtnetworkauth
Please note that when you install Qt for WASM version 6 and above, the installation will not
be functional unless you install a non-WASM desktop version of Qt alongside it.
You can do this automatically with the --autodesktop
flag:
$ aqt install-qt linux desktop 6.2.0 wasm_32 -m qtcharts qtnetworkauth --autodesktop
ツールをインストールする
aqt list-tool コマンドを使って、Windows Desktopで利用できるツールを調べてみましょう。
$ aqt list-tool windows desktop
tools_vcredist
...
tools_qtcreator
tools_qt3dstudio
tools_openssl_x86
tools_openssl_x64
tools_openssl_src
tools_ninja
tools_mingw
tools_mingw90
tools_ifw
tools_conan
tools_cmake
Let's see what tool variants are available in tools_mingw
:
$ aqt list-tool windows desktop tools_mingw
qt.tools.mingw47
qt.tools.win32_mingw48
qt.tools.win32_mingw482
qt.tools.win32_mingw491
qt.tools.win32_mingw492
qt.tools.win32_mingw530
qt.tools.win32_mingw730
qt.tools.win32_mingw810
qt.tools.win64_mingw730
qt.tools.win64_mingw810
このコマンドの出力は、以下の aqt install-tool で使える値のリストになります。以下のように、--l
または --long
フラグを使用して詳細を調べてみましょう。
$ aqt list-tool windows desktop tools_mingw -l
Tool Variant Name Version Release Date
=============================================================
qt.tools.mingw47 4.7.2-1-1 2013-07-01
qt.tools.win32_mingw48 4.8.0-1-1 2013-07-01
qt.tools.win32_mingw482 4.8.2 2014-05-08
qt.tools.win32_mingw491 4.9.1-3 2016-05-31
qt.tools.win32_mingw492 4.9.2-1 2016-05-31
qt.tools.win32_mingw530 5.3.0-2 2017-04-27
qt.tools.win32_mingw730 7.3.0-1-202004170606 2020-04-17
qt.tools.win32_mingw810 8.1.0-1-202004170606 2020-04-17
qt.tools.win64_mingw730 7.3.0-1-202004170606 2020-04-17
qt.tools.win64_mingw810 8.1.0-1-202004170606 2020-04-17
The -l
flag causes aqt list-tool to print a table
that shows plenty of data pertinent to each tool variant available in tools_mingw
.
aqt list-tool additionally prints the 'Display Name'
and 'Description' for each tool if your terminal is wider than 95 characters;
terminals that are narrower than this cannot display this table in a readable way.
Please be aware that the tool tools_mingw90
appears to be mislabelled:
$ aqt list-tool windows desktop tools_mingw90 -l
Tool Variant Name Version Release Date
=============================================================
qt.tools.win64_mingw900 9.0.0-1-202203221220 2022-03-22
$ aqt list-tool windows desktop tools_mingw90 -l
Tool Variant Name Version Release Date Display Name Description
============================================================================================================
qt.tools.win64_mingw900 9.0.0-1-202203221220 2022-03-22 MinGW 11.2.0 64-bit MinGW-builds 11.2.0
64-bit toolchain with
gcc 11.2.0
The 'narrow display' for tools_mingw90
cuts off the two columns of the table that
show you what's really in that package: MinGW 11.2.0 64-bit
.
If you are using the win64_mingw
architecture for Qt 6.2.2+, then this is
probably the compiler you want to install (see long_modules explanation).
Now let's install mingw
, using the aqt install-tool command.
This command receives four parameters:
ホストオペレーティングシステム(Windows、Mac、Linux)
ターゲットSDK(デスクトップ、android、ios、winrt)
The name of the tool (this is
tools_mingw
in our case)(Optional) The tool variant name. We saw a list of these when we ran aqt list-tool with the
tool name
argument filled in.
To install mingw
, you could use this command (please don't):
$ aqt install-tool windows desktop tools_mingw # please don't run this!
Using this command will install every tool variant available in tools_mingw
;
in this case, you would install 10 different versions of the same tool.
For some tools, like qtcreator
or ifw
, this is an appropriate thing to do,
since each tool variant is a different program.
However, for tools like mingw
and vcredist
, it would make more sense to use
aqt list-tool to see what tool variants are available,
and then install just the tool variant you are interested in, like this:
$ aqt install-tool windows desktop tools_mingw qt.tools.win64_mingw730
aqt install-tool
は、各ツールに関連する``installscript.qs`` を認識しないことに注意してください。これらのツールを標準のGUIインストーラでインストールする場合、インストーラは``installscript.qs`` スクリプトを使ってシステムに追加の変更を加えることができます。これらの変更が必要な場合、aqt
はこのスクリプトを実行することができないので、変更を加えるのはあなたの責任になります。
Qtアーカイブのサブセットをインストールする[上級編]
はじめに
お気づきかもしれませんが、デフォルトでは aqt install-qt
は多くのアーカイブをインストールしますが、その必要はないかもしれませんし、一般的なインストールでは必要以上のディスク容量を消費します。モジュール debug_info
をインストールした場合、1 GB以上のデータがインストールされている可能性があります。この節では、Qtインストールのフットプリントを減らすための手助けをします。
注釈
Be careful about using the --archives
flag; it is marked Advanced
for a reason!
It is very easy to misuse this command and end up with a Qt installation that
is missing the components that you need.
Don't use it unless you know what you are doing!
Qtの最小インストール
通常、aqt install-qt
を実行すると、このプログラムはダウンロード、抽出、インストールしているアーカイブの長いリストを出力します。このリストには、qtbase
、qtmultimedia
、qt3d
、そして約25項目が含まれています。これらのアーカイブのどれを実際にインストールするかは、--archives
フラグを使って選択することができます。 --archives
フラグは、Qtの基本インストールモジュールと``debug_info``モジュールの2つのモジュールにしか影響しません。
注釈
このドキュメントでは、"modules", "archives", "base Qt installation" はそれぞれ別のものを指しており、ここで定義されています:
Archives: このコンテキストでは、Archive は 7-zipで圧縮されたファイルのバンドルです。これはディスクドライブ上に拡張子``.7z``"のファイルとして存在します。
Modules: Qtリポジトリが一連のアーカイブをモジュールとして編成しています。module には、ひとつか複数の archives が含まれます。
the base Qt installation: 定義上、これは20から30の**archives** を含む単なる module です。このドキュメントでは、さまざまな事情から**module**ではなく、 the base Qt installation とよんでいます。
aqt install-qt
はデフォルトでこのモジュールをインストールします。このモジュールを``aqt install-qt --modules`` で指定することはできません。
aqt list-qt--modules
コマンドはこのモジュールの説明を表示できません。aqt
はQtリポジトリに存在するモジュールの名前を読みやすく書きやすくするために変換します。the base Qt installation の名前を同じ規則を使って変換された場合、名前は空になります。base Qt installation モジュールの完全修飾名は通常、
qt.qt6.620.gcc_64
のようなものです。qtcharts
モジュールの完全修飾名は通常、qt.qt6.620.qtcharts.gcc_64
のようなものです。プレフィックスqt.qt6.620.``とサフィックス
.gcc_64``を持つ20個のモジュールのリストを読み書きするのは難しいでしょう。なぜならこれらの部分は反復的で意味がないからです。ただ``qtcharts`` の部分だけが役に立つからです。
gcc_64アーキテクチャを使ってQt 5.15.2をLinuxデスクトップにインストールしたいとしましょう。qtbase
アーカイブには、動作中のQtインストールに最低限必要なものが含まれています。また、--archives
フラグを付けて単独でインストールすることもできます。
$ aqt install-qt linux desktop 5.15.2 --archives qtbase
今回、``aqt install-qt``は、デフォルトでインストールされる約27のアーカイブではなく、``qtbase``という1つのアーカイブだけをインストールします。
最小インストール数を超えるインストール
qtbase``アーカイブに必要な機能が欠けているとします。
--archives qtbase``フラグを使用すると、``aqt install-qt``は約27のアーカイブを省略します。``aqt list-qt --archives``コマンドでこれらのアーカイブのリストを表示することができます:
$ aqt list-qt linux desktop --archives 5.15.2 gcc_64
icu qt3d qtbase qtconnectivity qtdeclarative qtgamepad qtgraphicaleffects qtimageformats
qtlocation qtmultimedia qtquickcontrols qtquickcontrols2 qtremoteobjects qtscxml
qtsensors qtserialbus qtserialport qtspeech qtsvg qttools qttranslations qtwayland
qtwebchannel qtwebsockets qtwebview qtx11extras qtxmlpatterns
ここでは、関心のあるQtのバージョンと使用しているアーキテクチャの2つの引数を持つ``--archives``フラグを使用しました。その結果、コマンドはベース(最小ではない)Qtインストールの一部であるアーカイブのリストを出力しました。
qtmultimedia
、qtdeclarative
、``qtsvg``を使う必要があり、それ以外は何も使わないとしましょう。``qtbase``アーカイブは最低限動作するQtインストールに必要であることを覚えておいてください。これらのアーカイブは次のコマンドを使ってインストールできます:
$ aqt install-qt linux desktop 5.15.2 --archives qtbase qtmultimedia qtdeclarative qtsvg
アーカイブを指定してモジュールをインストールする
aqt v2.1.0以降では、--archives``フラグはQtの基本インストールと``debug_info``モジュールにのみ適用されます。aqtの以前のバージョンでは、
--archives``フラグを付けてモジュールをインストールする場合、ユーザはモジュールごとにアーカイブを指定する必要がありました。指定しないとインストールされませんでした。このようなミスを防止するために、この動作を変更しました。
モジュール``qtcharts``と``qtlottie``を使って、最低限のQt 5.15.2をインストールする必要があるとしましょう。
$ aqt install-qt linux desktop 5.15.2 --modules qtcharts qtlottie --archives qtbase
このコマンドは3つのアーカイブを正しくインストールします。1つは``qtbase``用で、もう1つは2つのモジュール用です。このコマンドをaqtの以前のバージョンで使用しようとすると、2つのモジュールは``--archives``リストに指定されていなかったので、インストールされませんでした。
注釈
qtbase``アーカイブを省略したり、他のアーカイブやモジュールが依存しているアーカイブを省略することで、
--archives``フラグを誤用することもできます。プログラムをコンパイルしようとしてコンパイルが失敗するまで、問題があることに気づかないかもしれません。
``debug_info``モジュールのインストール
ここで、debug_info``モジュールをインストールする必要があるとしましょう。このモジュールは非常に大きく、約1.0GBです。すべてをインストールしたくないので、``aqt install-qt --archives``を使ってインストールしたいアーカイブを選ぶことができます。この場合の
--archives``フラグは
``aqt list-qt --archives``で、どのアーカイブが``debug_info``モジュールの一部であるかを表示します。
$ aqt list-qt linux desktop --archives 5.15.2 gcc_64 debug_info
qt3d qtbase qtcharts qtconnectivity qtdatavis3d qtdeclarative qtgamepad qtgraphicaleffects
qtimageformats qtlocation qtlottie qtmultimedia qtnetworkauth qtpurchasing qtquick3d
qtquickcontrols qtquickcontrols2 qtquicktimeline qtremoteobjects qtscript qtscxml qtsensors
qtserialbus qtserialport qtspeech qtsvg qttools qtvirtualkeyboard qtwayland qtwebchannel
qtwebengine qtwebglplugin qtwebsockets qtwebview qtx11extras qtxmlpatterns
ここにはたくさんのアーカイブがあります。``debug_info``アーカイブと他のすべてのモジュール/Qtベースインストールのアーカイブとの間に名前の衝突があることに注意してください。これは、利用可能な他のほとんどすべてのアーカイブに対応する``debug_info``アーカイブがあるからです。
``qtcharts``と``debug_info``つきでQtをインストールし、いくつかのアーカイブを指定しましょう。
$ aqt install-qt linux desktop --modules qtcharts debug_info \
--archives qtcharts qtbase qtdeclarative
ここで行ったことに注目してください:qtcharts
モジュールと``debug_info``モジュールを指定し、qtbase``アーカイブ、``qtcharts``アーカイブ、``qtdeclarative
アーカイブを指定しました。これで合計6つのアーカイブがインストールされます:
debug_info``モジュールからの3つのアーカイブ ``qtbase
、qtcharts
、qtdeclarative
qtcharts``モジュールからのアーカイブ``qtcharts
、および基本Qtインストールの``qtbase``と``qtdeclarative``の2つのアーカイブです。
注釈
現在、aqt install-qt``は、基本Qtインストールから対応するモジュールをインストールせずに、``debug_info
モジュールからアーカイブをインストールすることはできません。例えば、通常の``qtbase``アーカイブをインストールせずに、qtbase``用の``debug_info
アーカイブをインストールすることはできません。