Getting Qt Sources from the Git repository

Introduction

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.

Note: Qt sources can also be installed using Qt Online Installer, downloaded as archives from the Qt Account (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 command.

Note: Qt 5 and Qt 6 share the same repository, and you will work against the qt5 repository even if you use Qt 6.

Preparations

Start by reviewing Building Qt Sources 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.

Cloning the Qt Git repository

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.8.0 git://code.qt.io/qt/qt5.git .

You can also use the https protocol.

git clone --branch v6.8.0 https://code.qt.io/qt/qt5.git .

To test out the latest development version, omit the --branch argument.

Initializing the Qt submodules

Next, create the build directory qt-build. Within this directory, run the configure command with the -init-submodules option.

qt-sources/configure -init-submodules

This will recursively initialize all Qt submodules in your qt-sources directory, which might take some time.

Note that -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 argument.

qt-sources/configure -init-submodules -submodules qtdeclarative

This will initialize qtdeclarative and required submodules.

Building Qt

With Qt sources set up, proceed to build Qt for your platform as outlined in Building Qt Sources. The -init-repository argument is only required during the initial Qt configuration and after switching branches.

Contributing to Qt

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.

© 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.