Skip to content

Repository files navigation

QML Template

A cross-platform C++ / Qt Quick application base for Windows, Linux and macOS.

Application identity lives in one place: src/appinfo.h holds the name, executable, bundle id, version and copyright, and everything else is derived from it, the CMake target, the Windows resource script, the macOS Info.plist, the Linux .desktop entry and the CI artifact names. The Qt version is pinned once in CMakeLists.txt, and the CI workflow reads that same line, so the two cannot drift apart.

For building I recommended CMake Tools extension.

The presets are named identically on every platform, so the same two commands work everywhere:

cmake --preset x64-Clang-Debug
cmake --build --preset x64-Clang-Debug

cmake --workflow --preset x64-Clang-Package produces a distribution under artifacts/<platform>-<arch>/: a small launcher sitting next to an app0/ directory that holds the real binary and the Qt runtime, so what a user opens stays readable instead of showing a hundred libraries. On macOS the .app bundle plays that role instead.

Releases are cut with python scripts/release.py prepare <version> and, after the pull request is merged, python scripts/release.py tag <version>; pushing the tag drives the workflow that builds Windows, Linux and macOS archives for x64 and arm64 see docs/release-use.md.

Point QT_KIT_DIR in CMake<Platform>Presets.json at your own Qt installation before the first build.

Required

  • QT
  • Python
  • VSCode

Required VSCode extensions

  • CMake Tools
  • Clang-Format
  • clangd
  • QT Extension Pack

Example workspace

{
  "folders": [
    {
      "path": "sources"
    }
  ],

  "settings": {
    "cmake.useCMakePresets": "always",
    "cmake.configureOnOpen": true,

    "cmake.useVsDeveloperEnvironment": "always",

    "cmake.debugConfig": {
      "environment": [
        {
          "name": "PATH",
          "value": "C:\\Qt\\6.11.1\\msvc2022_64\\bin;${env:PATH}"
        }
      ]
    },

    "C_Cpp.intelliSenseEngine": "Disabled",

    "clangd.arguments": [
      "--background-index",
      "--clang-tidy",
      "--completion-style=detailed",
      "--header-insertion=never",
      "--compile-commands-dir=${workspaceFolder}/.build/x64-Clang-Debug"
    ],

    "clang-format.executable": "clang-format",
	
	"qt-qml.qmlls.enabled": true,
    "qt-qml.qmlls.customExePath": "C:\\Qt\\6.11.1\\msvc2022_64\\bin\\qmlls.exe",
    "qt-qml.qmlls.additionalImportPaths": [
      "C:\\Qt\\6.11.1\\msvc2022_64\\qml",
      "${workspaceFolder}\\.build\\x64-Clang-Debug"
    ],
	
    "[qml]": {
      "editor.defaultFormatter": "TheQtCompany.qt-qml"
    },

    "[python]": {
      "editor.defaultFormatter": "charliermarsh.ruff",
      "editor.formatOnSave": true
    },
	
	"files.associations": {
        "**/i18n/*.ts": "xml"
    }

    "files.insertFinalNewline": true
  },

  "extensions": {
    "recommendations": [
      "llvm-vs-code-extensions.vscode-clangd",
      "ms-vscode.cmake-tools",
      "xaver.clang-format",
	  "theqtcompany.qt-core",
      "theqtcompany.qt-qml",
      "charliermarsh.ruff"
    ]
  }
}

About

A cross-platform C++ / Qt Quick application template for Windows, Linux and macOS that I personally use.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages