Qt 6 Documentation

repository·dev·Indexed 23 days ago

https://github.com/qt/qt5

Source code and build instructions for Qt 6, a cross-platform application development framework. Includes guides for building from source using CMake and Ninja on Linux, macOS, and Windows, configuring build types, managing submodules via init-repository, and setting up CI environments on CentOS and OpenSUSE.

Tokens
20.5K
Snippets
72
Records
135
Agent score
82%

What's inside Qt 6

  1. Use the Android Gradle Project to pre-cache dependencies for COIN

    dev

    The Android Gradle Project for COIN is a minimal project designed to pre-cache Gradle dependencies during the provisioning stage. This is used to ensure that subsequent Qt builds and tests can run successfully using the --offline flag by avoiding network downloads.

    This project caches dependencies for the following components:

    • com.android.application: Required for Qt test/example APK builds.
    • com.android.library: Required for Qt JAR builds.
    • android.dynamic.feature: Required for Feature Delivery tests.
    • org.jetbrains.kotlin.android: Required by certain Qt modules.
    • org.qtproject.qt.gradleplugin: Used by Qt for Android Studio projects.
    • AndroidX: Used by app builds.
  2. Reduce disk usage using --alternates

    dev

    To keep a Qt5 checkout small, you can use the --alternates <path to other Qt5 repo> option. This makes the current checkout use the object store of an existing full Qt5 checkout as an alternate, storing only unique objects in its own store.

    Warning: This makes the repository dependent on the alternate path. To make the repositories independent after cloning, use the --copy-objects option, which automatically runs git repack -a in each submodule. Note that using --copy-objects negates the disk usage benefits of using --alternates.

  3. Initialize the Qt repository with init-repository

    dev

    After performing an initial git clone of the Qt supermodule, use the ./init-repository script to check out all required submodules. The script fetches submodules from canonical URLs inferred from the clone's origin.

    To perform a standard initialization of the maintained modules included in standard Qt releases, run the script without additional arguments (this uses the default subset: essential,addon,preview,deprecated).

    ./init-repository
  4. Build and install Qt documentation

    dev

    After the main Qt build is complete, you can build and install the documentation using CMake targets. Note that building documentation is only tested on desktop platforms.

    • Build documentation: Use the docs target.
    • Install documentation: Use the install_docs target. Documentation is installed to the path specified by the -docdir argument during configuration.
  5. Build selected Qt modules only

    dev

    If you only need a subset of Qt, you can save time by building specific repositories and their dependencies using ninja. After running ./configure, use the ninja <repo-name>/all command.

    ./configure
    ninja qtdeclarative/all
  6. System requirements for building Qt 6

    dev

    To build Qt 6, ensure your environment meets the following requirements:

    • C++ compiler: Must support the C++17 standard.
    • CMake: Build system generator.
    • Ninja: Build tool (automatically chosen by CMake if installed).
    • Python 3: Required for configuration scripts.

    Platform-specific requirements:

    • Linux/Mac: Standard shell environment.
    • Windows:
      • A supported compiler (Visual Studio 2022 or later, or MinGW-builds gcc 13.1 or later).
      • Python 3 installed and available in the PATH.
  7. Build Qt 6 on Linux or macOS

    dev

    To build Qt 6 on Linux or macOS, navigate to the source package directory, run the configure script with a desired prefix, and then use CMake to build.

    Example of a standard build using a local qtbase directory as the installation prefix:

    cd <path>/<source_package>
    ./configure -prefix $PWD/qtbase
    cmake --build .
  8. Build Qt 6 on Windows

    dev

    To build Qt 6 on Windows:

    1. Open a command prompt.
    2. Ensure your compiler (Visual Studio 2022+ or MinGW-builds gcc 13.1+) and Python 3 are in your PATH.
    3. Navigate to the source package and run the configuration and build commands.
    cd <path>\<source_package>
    configure -prefix %CD%\qtbase
    cmake --build .
  9. Configure submodule subsets with --module-subset

    dev

    You can control which submodules are initialized using the --module-subset=<module1>,<module2>... or -submodules <module1>,<module2>... options.

    Available Subset Keywords:

    • all: Clones all known modules.
    • default: A shorthand for essential,addon,preview,deprecated (the standard Qt release set).
    • essential, addon, preview, deprecated, obsolete, additionalLibrary, ignore: Refers to module classes identified by status= in .gitmodules.
    • existing: References submodules that are already initialized.
    • qtrepotools: Implicitly added to ensure git commit hooks are available.

    Exclusion Syntax: You can exclude specific modules or classes from a set by prefixing them with a dash. For example, all,-ignore includes everything except modules marked as ignore.

  10. Configure Qt 6 build types

    dev

    The configure script accepts several options to control the build output. Use ./configure -help to see all available options.

    Common options:

    • -release: Compile and link Qt with debugging turned off.
    • -debug: Compile and link Qt with debugging turned on.
    • -developer-build: A specialized build for developers that enables more autotests and builds debug versions of libraries.
    # Example: Release build
    ./configure -prefix $PWD/qtbase
    cmake --build .
    
    # Example: Developer build
    ./configure -developer-build
    cmake --build .
  11. Configure Windows resolution to 1280x800

    dev

    If 1280x800 is not available in the display settings, you can force it via the Registry:

    1. Select a resolution with a width of 1280 (e.g., 1280x960).
    2. Open regedit and navigate to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration
    3. Locate the key/folder and its subkeys (typically 00/00) corresponding to the resolution you selected.
    4. Change every height value (e.g., 960) to 800.
    5. Restart Windows.
  12. Switch to GNOME Classic User Interface

    dev

    Standard Wayland display servers in GNOME can cause Autotest failures by keeping terminal sessions stuck in the Activities Overview. To avoid this, switch to the GNOME Classic interface:

    1. Execute the script to disable automounting (prevents dconf update crashes in GNOME Classic):
      ./01-disable-automounting.sh
    2. Logout.
    3. On the login screen, Select the user (this is required for the menu to appear).
    4. Select 'GNOME Classic' from the dropdown menu.
    5. Reboot.
    ./01-disable-automounting.sh