此页面描述了配置和构建的过程,针对 Qt for Windows . To download and install a pre-built Qt for Windows, follow the instructions on the Qt 快速入门 页面。
Qt sources can be installed in Qt Online Installer. Source packages are also available through Git , as archives in the Qt 帐户 (commercial users), and on download.qt.io (open-source users).
If you install the sources through Qt Online Installer, they will be available in the Qt installation directory, for instance
C:\Qt\6.8.5\Src
.
If you downloaded the source archive, extract it to a directory of your choice, for instance
C:\dev\Qt\src
.
注意: The path to the source directory must not contain any spaces or Windows-specific file system characters. The path should also be kept short. This prevents issues with too long file paths in the compilation phase.
To build Qt from sources you need a build environment with a supported compiler and various build tools.
| 工具 | 支持版本 | 描述 |
|---|---|---|
| CMake |
Version 3.16 and newer (3.17 and newer for
-debug-and-release
builds 3.21 and newer for
-static
builds).
|
Required for configuring the Qt build. Available in Qt Online Installer and on cmake.org . |
| Ninja | - | Recommended tool for building Qt. Available in Qt Online Installer and on ninja-build.org . |
| Python | Version 3 | Required build tool. Windows installers are available on python.org , or from the Microsoft Store . |
The executables
cmake.exe
,
ninja.exe
,和
python.exe
must be available in your build environment. Add the respective directory to your
PATH
环境变量。
The following compilers and configurations are supported in Qt 6.8:
| 操作系统 | 体系结构 | 编译器 | 注意事项 |
|---|---|---|---|
| Windows 10 (1809 或更高版本) |
x86_64
|
MSVC 2022, Mingw-w64 13.1 | |
| Windows 11 |
x86_64
|
MSVC 2022, Mingw-w64 13.1 | |
| ARM 中的 Windows |
ARM64
|
MSVC 2022 |
注意: Currently Qt does not support ARM64EC on Windows on ARM devices.
QDoc uses Clang to parse C++ code. If you wish to build QDoc manually, refer to 为 QDoc 安装 Clang 对于特定构建要求。
Qt GRPC
and
Qt Protobuf
require installing
gRPC
and
Protobuf
packages. You can find the installation instructions for the packages in the
Example of installation for Windows using vcpkg
.
For MSVC, do one of the following:
"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat" amd64
For Mingw-w64: Add Mingw-w64 to
PATH
environment variable:
Set PATH=C:\qt\tools\mingw1120_64\bin;%PATH%
To configure your build, create a build directory and run the
configure.bat
script in this directory:
mkdir C:\dev\qt-build cd C:\dev\qt-build C:\dev\Qt\src\configure.bat
By default, Qt is configured for installation in the
C:\Qt\Qt-major.minor.patch
directory, where the major.minor.patch triplet represents the Qt version being built. This can be changed by using the
-prefix
option. See the list of
Qt 配置选项
to tweak further.
Then build the libraries and tools:
cmake --build . --parallel
Period after
--build
means current folder.
After building, you need to install the libraries and tools in the desired path (unless you enabled a developer build :
cmake --install .
After Qt is installed, you can start building applications with it.
If you work from the command line, consider adding the Qt tools to your
PATH
environment variable as follows:
set PATH=C:\Qt\Qt-major.minor.patch\bin;%PATH%
If you plan to use Qt from an IDE, you need to register the Qt version explicitly there. For Qt Creator, see Qt Creator: Adding Qt Versions .