This section describes how to get the Qt sources through the Git version control system. This is useful in software development processes that already use Git and when testing different Qt versions. It is also essential if you plan to contribute to Qt.
注意: Qt sources can also be installed using Qt Online Installer, downloaded as archives from the Qt 帐户 (commercial users), or from download.qt.io (open-source users).
Qt is developed and maintained in several Git submodules tied together in a
qt5
super module. Getting the Qt sources from Git involves cloning the top-level Git repository via the Git command line and initializing the submodules using the Qt
configure
命令。
注意:
Qt 5 and Qt 6 share the same repository, and you will work against the
qt5
repository even if you use Qt 6.
Start by reviewing 构建 Qt 源 and the requirements section for your platform to make sure all prerequisites have been installed. In addition, you will need a recent version of Git.
When planning where to clone the Qt sources, keep in mind that Qt supports out-of-source builds, where the source code resides separately from build artifacts. This keeps the Git clone clean and makes it possible to build different versions of Qt from the same source tree. In this overview, the directory containing the Qt sources is referred to as
qt-sources
, while the one containing build artifacts is referred to as
qt-build
.
Begin by creating the
qt-sources
directory. From within this directory, use Git to clone the sources. In the following, we will use the Git command line interface. Be aware of the trailing '.' character indicating that Qt is cloned into the current directory.
git clone --branch v6.7.2 git://code.qt.io/qt/qt5.git .
You can also use the https protocol.
git clone --branch v6.7.2 https://code.qt.io/qt/qt5.git .
To test out the latest development version, omit the
--branch
自变量。
Next, create the build directory
qt-build
. Within this directory, run the
configure
command with the
-init-submodules
选项。
qt-sources/configure -init-submodules
This will recursively initialize all Qt submodules in your
qt-sources
directory, which might take some time.
注意,
-init-submodules
can be combined with other
configure
arguments. If you know the Qt submodules you will work with, reduce the configuration time by using the
-submodules
自变量。
qt-sources/configure -init-submodules -submodules qtdeclarative
This will initialize
qtdeclarative
and required submodules.
With Qt sources set up, proceed to build Qt for your platform as outlined in
构建 Qt 源
。
-init-repository
argument is only required during the initial Qt configuration and after switching branches.
For those planning to contribute to Qt, specify the
-codereview-username
the first time you configure Qt.
qt-sources/configure -init-submodules --codereview-username <Gerrit username>
For more information on contributing to Qt and creating a Gerrit username, consult the The Qt Project homepage.