Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qtquickcontrols-configuration.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-configuration.html
6 \keyword Qt Quick Controls Configuration File
7 \title Qt Quick Controls Configuration File
8 \keyword Qt Quick Controls 2 Configuration File
9
10 Qt Quick Controls support a special configuration file, \c qtquickcontrols2.conf,
11 which is built into an application's resources.
12
13 The configuration file can specify the preferred style and certain style-specific
14 attributes. The following example specifies that the preferred style is the \l {Material style}.
15 Furthermore, when the application is run with the Material style, its theme is light and the
16 accent and primary colors are teal and blue grey, respectively. However, if the application
17 is run with the \l {Universal style} instead, the accent color is red and the appropriate theme
18 is chosen based on the system theme colors.
19
20 \code
21 [Controls]
22 Style=Material
23
24 [Universal]
25 Theme=System
26 Accent=Red
27
28 [Material]
29 Theme=Light
30 Accent=Teal
31 Primary=BlueGrey
32 \endcode
33
34 It is possible to specify a custom location for the configuration file with
35 the \l {Supported Environment Variables in Qt Quick Controls}
36 {QT_QUICK_CONTROLS_CONF} environment variable.
37
38 \section1 Controls Section
39
40 The following values can be specified in a \c Controls section of the
41 configuration file:
42
43 \table
44 \header
45 \li Variable
46 \li Description
47 \row
48 \li \c Style
49 \li Specifies the style to run the application with.
50 The value can be the name of one of the \l {Available Styles}{built-in styles}
51 or a \l {Creating a Custom Style}{custom style}.
52 \row
53 \li \c FallbackStyle
54 \li Specifies the style to use for controls that are not implemented.
55 The style must be one of the \l {Available Styles}{built-in styles}.
56 By default, the \l {Basic Style}{Basic} style is used.
57 \endtable
58
59 \section1 Imagine Section
60
61 The following table lists values that can be used to configure the
62 \l {Imagine style} in an \c Imagine section of the configuration file:
63
64 \include qquickimaginestyle.qdocinc conf
65
66 \section1 Material Section
67
68 The following table lists values that can be used to configure the
69 \l {Material style} in a \c Material section of the configuration file:
70
71 \include qquickmaterialstyle.qdocinc conf
72
73 \section1 Universal Section
74
75 The following table lists values that can be used to configure the
76 \l {Universal style} in a \c Universal section of the configuration file:
77
78 \include qquickuniversalstyle.qdocinc conf
79
80 \section1 Font Configuration
81
82 The default \l {Control::font}{font} can be specified in a \c Font sub-group
83 in each style's section in the configuration file. The \c Font sub-group can
84 be defined in two alternative ways:
85
86 \code
87 [Basic]
88 Font\Family=Open Sans
89 Font\PixelSize=20
90
91 [Material\Font]
92 Family=Open Sans
93 PixelSize=20
94 \endcode
95
96 Supported font attributes:
97 \table
98 \header
99 \li Variable
100 \li Description
101 \row
102 \li \c Family
103 \li The \l {QFont::family}{font family}.
104 \row
105 \li \c PointSize
106 \li The \l {QFont::pointSizeF}{point size}.
107 \row
108 \li \c PixelSize
109 \li The \l {QFont::pixelSize}{pixel size}.
110 \row
111 \li \c StyleHint
112 \li The \l {QFont::styleHint}{style hint}.
113 Available values: \c SansSerif, \c Helvetica, \c Serif, \c Times, \c TypeWriter, \c Courier,
114 \c OldEnglish, \c Decorative, \c Monospace, \c Fantasy, \c Cursive.
115 \row
116 \li \c Weight
117 \li The \l {QFont::}{weight}. Qt uses a weighting scale from \c 1 to \c 1000 compatible with OpenType. A weight of \c 1 will be thin,
118 whilst \c 1000 will be extremely black.
119 Available pre-defined weights: \c Thin (100), \c ExtraLight (200), \c Light (300), \c Normal (400),
120 \c Medium (500), \c DemiBold (600), \c Bold (700), \c ExtraBold (800),
121 \c Black (900).
122 \row
123 \li \c Style
124 \li The \l {QFont::}{style}.
125 Available values: \c StyleNormal, \c StyleItalic, \c StyleOblique.
126 \endtable
127
128 \section1 Palette Configuration
129
130 The default \c palette can be configured for each style using the
131 \c Palette sub-group in the configuration file. The \c Palette sub-group can be
132 defined in two alternative ways:
133
134 \code
135 [Fusion]
136 Palette\Window=#dedede
137 Palette\WindowText=#212121
138 \endcode
139
140 or:
141 \code
142 [Fusion\Palette]
143 Window=#dedede
144 WindowText=#212121
145 \endcode
146
147 See \l [QtQuick]{Palette} QML type for more information.
148
149 \section1 Using the Configuration File in a Project
150
151 In order to make it possible for Qt Quick Controls to find the configuration file,
152 it must be built into application's resources using the \l {The Qt Resource System}.
153 Here's an example \c .qrc file:
154
155 \code
156 <!DOCTYPE RCC><RCC version="1.0">
157 <qresource prefix="/">
158 <file>qtquickcontrols2.conf</file>
159 </qresource>
160 </RCC>
161 \endcode
162
163 \note Qt Quick Controls uses a file selector to load the configuration file. It
164 is possible to provide a different configuration file for different platforms and
165 locales. See \l QFileSelector documentation for more details.
166
167 Finally, the \c .qrc file must be listed in the application's \c .pro file so that
168 the build system knows about it. For example:
169
170 \code
171 RESOURCES = application.qrc
172 \endcode
173
174 \section1 Related Information
175
176 \list
177 \li \l{Styling Qt Quick Controls}
178 \li \l{Supported Environment Variables in Qt Quick Controls}
179 \endlist
180*/