Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqstylekitcustomtheme.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6
8
9/*!
10 \qmltype CustomTheme
11 \inqmlmodule Qt.labs.StyleKit
12 \brief Defines a named custom theme.
13
14 CustomTheme lets you add additional themes beyond
15 \l {Style::light}{light} and \l {Style::dark}{dark}.
16 While the light and dark themes are applied \l {Style::themeName}{automatically} based on the
17 operating system's color scheme, a CustomTheme must be activated
18 explicitly by the application. Apart from this difference, all themes work the same way.
19
20 You can define any number of custom themes inside a \l Style.
21
22 \snippet CustomThemeSnippets.qml custom themes
23
24 To activate a CustomTheme, set \l Style::themeName to its name
25 from the application:
26
27 \snippet CustomThemeSnippets.qml change theme
28
29 You can also set a CustomTheme as the default theme at start-up:
30
31 \snippet CustomThemeSnippets.qml custom theme at start-up
32
33 The custom themes defined in a Style can be queried at runtime
34 from \l {Style::customThemeNames} or \l {Style::themeNames}.
35
36 \labs
37
38 \sa Theme, Style::themeName, Style::customThemeNames
39*/
40
41/*!
42 \qmlproperty string CustomTheme::name
43
44 The name of this theme. This is the value you assign to
45 \l {Style::themeName} to activate it.
46*/
47
48/*!
49 \qmlproperty Component CustomTheme::theme
50
51 The \l Theme component that defines the theme. It will
52 only be instantiated when the theme is activated.
53
54 Properties not set in the theme fall back to those defined in the \l Style.
55*/
56
61
62QString QQStyleKitCustomTheme::name() const
63{
64 return m_name;
65}
66
67void QQStyleKitCustomTheme::setName(const QString &newName)
68{
69 if (m_name == newName)
70 return;
71 m_name = newName;
72 emit nameChanged();
73}
74
76{
77 return m_theme;
78}
79
80void QQStyleKitCustomTheme::setTheme(QQmlComponent *newTheme)
81{
82 if (m_theme == newTheme)
83 return;
84 m_theme = newTheme;
85 emit themeChanged();
86}
87
88QT_END_NAMESPACE
89
90#include "moc_qqstylekitcustomtheme_p.cpp"
QObject * parent
Definition qobject.h:74
\inmodule QtCore
Definition qobject.h:106
QQmlComponent * theme() const
void setName(const QString &newName)
void setTheme(QQmlComponent *newTheme)
Combined button and popup list for selecting options.