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
qtquickcontrols-universal.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2017 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\page qtquickcontrols-universal.html
6
\title Universal Style
7
8
The Universal Style is based on the Microsoft Universal Design Guidelines.
9
\l {detailed-desc-universal}{More...}
10
11
\styleimport {QtQuick.Controls.Universal 2.12} {Qt 5.7}
12
13
\section1 Attached Properties
14
15
\list
16
\li \l {universal-accent-attached-prop}{\b accent} : color
17
\li \l {universal-background-attached-prop}{\b background} : color
18
\li \l {universal-foreground-attached-prop}{\b foreground} : color
19
\li \l {universal-theme-attached-prop}{\b theme} : enumeration
20
\endlist
21
22
\section1 Attached Methods
23
24
\list
25
\li color \l {color-attached-method}{\b color}(enumeration predefined)
26
\endlist
27
28
\section1 Detailed Description
29
\target detailed-desc-universal
30
31
The Universal style is a device-agnostic style based on the
32
Microsoft Universal Design Guidelines.
33
The Universal style has been designed to look good on all devices, from
34
phones and tablets to PCs.
35
36
\include style-screenshots.qdocinc {file} {Universal} {universal}
37
38
To run an application with the Universal style, see
39
\l {Using Styles in Qt Quick Controls}.
40
41
\note The Universal style is not a native Windows 10 style. The Universal
42
style is a 100% cross-platform Qt Quick Controls style implementation that
43
follows the Microsoft Universal Design Guidelines. The style runs on any
44
platform, and looks more or less identical everywhere. Minor differences
45
may occur due to differences in available system fonts and font rendering
46
engines.
47
48
\section2 Customization
49
50
The Universal style allows customizing four attributes, \l {universal-theme-attached-prop}{theme},
51
\l {universal-accent-attached-prop}{accent}, \l {universal-foreground-attached-prop}{foreground}, and
52
\l {universal-background-attached-prop}{background}.
53
54
\image qtquickcontrols-universal-attributes.png
55
56
Both attributes can be specified for any window or item, and they automatically
57
propagate to children in the same manner as \l {Control::font}{fonts}. In the
58
following example, the window and all three radio buttons appear in the dark
59
theme using a violet accent color:
60
61
\table
62
\row
63
\li
64
\qml
65
import QtQuick 2.12
66
import QtQuick.Controls 2.12
67
import QtQuick.Controls.Universal 2.12
68
69
ApplicationWindow {
70
visible: true
71
72
Universal.theme: Universal.Dark
73
Universal.accent: Universal.Violet
74
75
Column {
76
anchors.centerIn: parent
77
78
RadioButton { text: qsTr("Small") }
79
RadioButton { text: qsTr("Medium"); checked: true }
80
RadioButton { text: qsTr("Large") }
81
}
82
}
83
\endqml
84
\li
85
\image qtquickcontrols-universal-violet.png
86
\endtable
87
88
In addition to specifying the attributes in QML, it is also possible to
89
specify them via environment variables or in a configuration file. Attributes
90
specified in QML take precedence over all other methods.
91
92
\section3 Configuration File
93
94
\include qquickuniversalstyle.qdocinc conf
95
96
See \l {Qt Quick Controls Configuration File} for more details about the
97
configuration file.
98
99
\section3 Environment Variables
100
101
\include qquickuniversalstyle.qdocinc env
102
103
See \l {Supported Environment Variables in Qt Quick Controls} for the full
104
list of supported environment variables.
105
106
\section2 Dependency
107
108
The Universal style must be separately imported to gain access to the
109
attributes that are specific to the Universal style. It should be noted
110
that regardless of the references to the Universal style, the same
111
application code runs with any other style. Universal-specific attributes
112
only have an effect when the application is run with the Universal style.
113
114
If the Universal style is imported in a QML file that is always loaded, the
115
Universal style must be deployed with the application in order to be able
116
to run the application regardless of which style the application is run with.
117
By using \l {Using File Selectors with Qt Quick Controls}{file selectors},
118
style-specific tweaks can be applied without creating a hard dependency to
119
a style.
120
121
\section2 Pre-defined Universal Colors
122
123
Available pre-defined colors:
124
\value Universal.Lime \stylecolor {#A4C400} {}
125
\value Universal.Green \stylecolor {#60A917} {}
126
\value Universal.Emerald \stylecolor {#008A00} {}
127
\value Universal.Teal \stylecolor {#00ABA9} {}
128
\value Universal.Cyan \stylecolor {#1BA1E2} {}
129
\value Universal.Cobalt \stylecolor {#3E65FF} {(default accent)}
130
\value Universal.Indigo \stylecolor {#6A00FF} {}
131
\value Universal.Violet \stylecolor {#AA00FF} {}
132
\value Universal.Pink \stylecolor {#F472D0} {}
133
\value Universal.Magenta \stylecolor {#D80073} {}
134
\value Universal.Crimson \stylecolor {#A20025} {}
135
\value Universal.Red \stylecolor {#E51400} {}
136
\value Universal.Orange \stylecolor {#FA6800} {}
137
\value Universal.Amber \stylecolor {#F0A30A} {}
138
\value Universal.Yellow \stylecolor {#E3C800} {}
139
\value Universal.Brown \stylecolor {#825A2C} {}
140
\value Universal.Olive \stylecolor {#6D8764} {}
141
\value Universal.Steel \stylecolor {#647687} {}
142
\value Universal.Mauve \stylecolor {#76608A} {}
143
\value Universal.Taupe \stylecolor {#87794E} {}
144
145
\b {See also} \l {Basic Style}, \l {Material Style}
146
147
\section1 Attached Property Documentation
148
149
\styleproperty {Universal.accent} {color}
150
\target universal-accent-attached-prop
151
This attached property holds the accent color of the theme. The property
152
can be attached to any window or item. The value is propagated to children.
153
154
The default value is \c Universal.Cobalt.
155
156
In the following example, the accent color of the highlighted button is
157
changed to \c Universal.Orange:
158
159
\table
160
\row
161
\li
162
\snippet qtquickcontrols-universal-accent.qml 1
163
\li
164
\image qtquickcontrols-universal-accent.png
165
\endtable
166
167
\note Even though the accent can be any \l {colorvaluetypedocs}{color}, it is
168
recommended to use one of the \l {pre-defined Universal colors} that have been
169
designed to work well with the rest of the Universal style palette.
170
171
\endstyleproperty
172
173
\styleproperty {Universal.background} {color}
174
\target universal-background-attached-prop
175
This attached property holds the background color of the theme. The property
176
can be attached to any window or item. The value is propagated to children.
177
178
The default value is theme-specific (light or dark).
179
180
In the following example, the background color of the pane is changed to
181
\c Universal.Steel:
182
183
\table
184
\row
185
\li
186
\snippet qtquickcontrols-universal-background.qml 1
187
\li
188
\image qtquickcontrols-universal-background.png
189
\endtable
190
191
\endstyleproperty
192
193
\styleproperty {Universal.foreground} {color}
194
\target universal-foreground-attached-prop
195
This attached property holds the foreground color of the theme. The property
196
can be attached to any window or item. The value is propagated to children.
197
198
The default value is theme-specific (light or dark).
199
200
In the following example, the foreground color of the button is set to \c
201
Universal.Pink:
202
203
\table
204
\row
205
\li
206
\snippet qtquickcontrols-universal-foreground.qml 1
207
\li
208
\image qtquickcontrols-universal-foreground.png
209
\endtable
210
211
\endstyleproperty
212
213
\styleproperty {Universal.theme} {enumeration}
214
\target universal-theme-attached-prop
215
This attached property holds whether the theme is light or dark. The property
216
can be attached to any window or item. The value is propagated to children.
217
218
Available themes:
219
\value Universal.Light Light theme (default)
220
\value Universal.Dark Dark theme
221
\value Universal.System System theme
222
223
Setting the theme to \c System chooses either the light or dark theme based
224
on the system theme colors. However, when reading the value of the theme
225
property, the value is never \c System, but the actual theme.
226
227
In the following example, the theme for both the pane and the button is set
228
to \c Universal.Dark:
229
230
\table
231
\row
232
\li
233
\snippet qtquickcontrols-universal-theme.qml 1
234
\li
235
\image qtquickcontrols-universal-theme.png
236
\endtable
237
238
\endstyleproperty
239
240
\section1 Attached Method Documentation
241
242
\stylemethod {color} {color} {enumeration} {predefined}
243
\target color-attached-method
244
This attached method returns the effective color value of the specified
245
\l {pre-defined Universal colors}{pre-defined Universal color}.
246
247
\qml
248
Rectangle {
249
color: Universal.color(Universal.Red)
250
}
251
\endqml
252
253
\endstylemethod
254
255
\section1 Related Information
256
257
\list
258
\li \l{Styling Qt Quick Controls}
259
\endlist
260
*/
qtdeclarative
src
quickcontrols
doc
src
qtquickcontrols-universal.qdoc
Generated on
for Qt by
1.14.0