1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\page qtquickcontrols2-styles.html
\title Styling Qt Quick Controls
\section1 Available Styles
Qt Quick Controls comes with a selection of styles.
\section2 Basic Style
\image qtquickcontrols2-basic-thumbnail.png
The \l {Basic Style} is a simple and light-weight all-round style that offers
the maximum performance for Qt Quick Controls.
\section2 Fusion Style
\image qtquickcontrols2-fusion-thumbnail.png
The \l {Fusion Style} is a platform-agnostic style that offers a desktop-oriented
look and feel for Qt Quick Controls.
\section2 Imagine Style
\image qtquickcontrols2-imagine-thumbnail.png
The \l {Imagine Style} is based on image assets. The style comes with a default
set of images which can easily be changed by providing a directory
with images using a predefined naming convention.
\section2 Material Style
\image qtquickcontrols2-material-thumbnail.png
The \l {Material Style} offers an appealing design based on the
\l {https://www.google.com/design/spec/material-design/introduction.html}
{Google Material Design Guidelines}, but requires more system resources than
the Basic style.
\section2 Universal Style
\image qtquickcontrols2-universal-thumbnail.png
The \l {Universal Style} offers an appealing design based on the
\l {https://dev.windows.com/design}{Microsoft Universal Design Guidelines},
but requires more system resources than the Basic style.
\section1 Using Styles in Qt Quick Controls
There are two ways of using styles in Qt Quick Controls:
run-time style selection and compile-time style selection.
\section2 Compile-Time Style Selection
Compile-time style selection involves using QML imports to specify the
style. For example, to import the Material style:
\qml
import QtQuick.Controls.Material
ApplicationWindow {
// ...
}
\endqml
Notice that QtQuick.Controls (which is responsible for run-time style
selection) is not imported. The fallback style is specified by the qmldir
of the style:
\badcode
module QtQuick.Controls.Material
# ...
import QtQuick.Controls.Basic auto
\endcode
The benefit of compile-time style selection is that the QtQuick.Controls plugin
is not used and therefore does not need to be deployed with the application.
Explicit imports are also necessary if your application is built
\l {Static Builds}{statically}.
\section2 Run-Time Style Selection
Run-time style selection involves importing \c QtQuick.Controls:
\qml
import QtQuick.Controls
\endqml
The QtQuick.Controls plugin will import the style and fallback
style that were set at runtime via one of the following approaches:
\list
\li \l[CPP]{QQuickStyle::setStyle()}
\li The \c -style command line argument
\li The \c QT_QUICK_CONTROLS_STYLE environment variable
\li The \c qtquickcontrols2.conf configuration file
\endlist
The priority of these approaches follows the order they are listed,
from highest to lowest. That is, using \c QQuickStyle to set the style will
always take priority over using the command line argument, for example.
The benefit of run-time style selection is that a single application binary
can support multiple styles, meaning that the end user can choose which
style to run the application with.
\section3 Using QQuickStyle in C++
\l[CPP]{QQuickStyle} provides C++ API for configuring a specific
style. The following example runs a Qt Quick Controls application
with the Material style:
\code
QQuickStyle::setStyle("Material");
\endcode
See the detailed description of \l[CPP]{QQuickStyle} for more
details.
\section3 Command line argument
Passing a \c -style command line argument is the convenient way to test different
styles. It takes precedence over the other methods listed below. The following
example runs a Qt Quick Controls application with the Material style:
\code
./app -style material
\endcode
\section3 Environment variable
Setting the \c QT_QUICK_CONTROLS_STYLE environment variable can be used to set
a system-wide style preference. It takes precedence over the configuration file
mentioned below. The following example runs a Qt Quick Controls application with
the Universal style:
\code
QT_QUICK_CONTROLS_STYLE=universal ./app
\endcode
See \l {Supported Environment Variables in Qt Quick Controls} for the full list
of supported environment variables.
\section3 Configuration file
Qt Quick Controls support a special configuration file, \c :/qtquickcontrols2.conf,
that is built into an application's resources.
The configuration file can specify the preferred style (may be overridden by either
of the methods described earlier) and certain style-specific attributes. The following
example specifies that the preferred style is the Material style.
\code
[Controls]
Style=Material
\endcode
See \l {Qt Quick Controls Configuration File} for more details about the
configuration file.
\section1 Related Information
\list
\li \l {Basic Style}
\li \l {Fusion Style}
\li \l {Imagine Style}
\li \l {Material Style}
\li \l {Universal Style}
\li \l {Customizing Qt Quick Controls}
\li \l {Using File Selectors with Qt Quick Controls}
\li \l {Deploying Qt Quick Controls Applications}
\li \l {Qt Quick Controls Configuration File}
\li \l {Supported Environment Variables in Qt Quick Controls}
\endlist
*/
|