A modular Qt 6 toolkit for building themed Qt Quick applications. Provides a reactive dark/light theme system and a matching set of Qt Quick Controls overrides, designed to be dropped into any project with a single add_subdirectory.
| CMake target | QML URI | Description |
|---|---|---|
ThemeToolKit::Theme |
io.github.ven96.theme 1.0 |
C++ singleton that drives dark/light switching |
ThemeToolKit::Style |
io.github.ven96.controls 1.0 |
Qt Quick Controls overrides + design tokens |
ThemeToolKit::Style depends on ThemeToolKit::Theme — linking Style is sufficient to pull in both.
- Qt ≥ 6.5 (
Quick,QuickControls2) - CMake ≥ 3.16
- C++20
add_subdirectory(QMLThemeToolKit)
target_link_libraries(MyApp PRIVATE ThemeToolKit::Style)
qt_import_qml_plugins(MyApp)include(FetchContent)
FetchContent_Declare(QMLThemeToolKit
GIT_REPOSITORY https://github.com/96Ven96/QMLThemeToolKit.git
GIT_TAG main
)
FetchContent_MakeAvailable(QMLThemeToolKit)
target_link_libraries(MyApp PRIVATE ThemeToolKit::Style)
qt_import_qml_plugins(MyApp)| Option | Default | Effect |
|---|---|---|
QMLTHEMETOOLKIT_THEME |
ON |
Build ThemeToolKit::Theme |
QMLTHEMETOOLKIT_STYLE |
ON |
Build ThemeToolKit::Style (requires Theme) |
QMLTHEMETOOLKIT_SETTINGS |
ON |
Fetch qsettings-mapper and expose ThemeSettings.h |
Set options before the add_subdirectory / FetchContent_MakeAvailable call:
set(QMLTHEMETOOLKIT_SETTINGS OFF) # skip if you don't persist theme preferences
add_subdirectory(QMLThemeToolKit)#include <QQmlApplicationEngine>
// Make the embedded QML modules visible to the engine.
engine.addImportPath("qrc:/qt/qml");
engine.loadFromModule("MyApp", "Main");ThemeManager is registered automatically as a QML singleton via QML_ELEMENT + QML_SINGLETON — no manual qmlRegisterSingletonInstance needed. Access it from C++ via ThemeManager::instance():
#include <ThemeManager.h>
ThemeManager::instance().setColorTheme(ThemeManager::Dark);import io.github.ven96.controls
// Style singleton — reactive design tokens
Rectangle {
color: Style.surfaceApp
Text {
color: Style.textPrimary
font.pixelSize: Style.fontSizeBody
}
}import QtQuick.Controls
import io.github.ven96.controls
Column {
Button { text: "Cancel" } // secondary style
Button { text: "Confirm"; highlighted: true } // primary style
SearchBar { placeholderText: "Filter..." }
Toast { id: toast }
}For the full component reference (tokens, SearchBar, Toast, Dialog) see QtQMLSyleKit/README.md.
When QMLTHEMETOOLKIT_SETTINGS=ON, include ThemeSettings.h to get a ready-made QSettings mapping:
#include <ThemeSettings.h>
QSettings s("MyOrg", "MyApp");
SettingsHelper::load<ThemeSettings>(s, ThemeManager::instance()); // on startup
SettingsHelper::save<ThemeSettings>(s, ThemeManager::instance()); // on change| Library | How it arrives |
|---|---|
cpp-template-toolkit |
FetchContent (only when QMLTHEMETOOLKIT_SETTINGS=ON) |
qsettings-mapper |
FetchContent (only when QMLTHEMETOOLKIT_SETTINGS=ON) |
Both use an if(NOT TARGET ...) guard: if your project already pulls in either library, CMake reuses the existing target and skips the fetch entirely.