Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
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:
84
85 \code
86 [Basic]
87 Font\Family=Open Sans
88 Font\PixelSize=20
89 \endcode
90
91 Supported font attributes:
92 \table
93 \header
94 \li Variable
95 \li Description
96 \row
97 \li \c Family
98 \li The \l {QFont::family}{font family}.
99 \row
100 \li \c PointSize
101 \li The \l {QFont::pointSizeF}{point size}.
102 \row
103 \li \c PixelSize
104 \li The \l {QFont::pixelSize}{pixel size}.
105 \row
106 \li \c StyleHint
107 \li The \l {QFont::styleHint}{style hint}.
108 Available values: \c SansSerif, \c Helvetica, \c Serif, \c Times, \c TypeWriter, \c Courier,
109 \c OldEnglish, \c Decorative, \c Monospace, \c Fantasy, \c Cursive.
110 \row
111 \li \c Weight
112 \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,
113 whilst \c 1000 will be extremely black.
114 Available pre-defined weights: \c Thin (100), \c ExtraLight (200), \c Light (300), \c Normal (400),
115 \c Medium (500), \c DemiBold (600), \c Bold (700), \c ExtraBold (800),
116 \c Black (900).
117 \row
118 \li \c Style
119 \li The \l {QFont::}{style}.
120 Available values: \c StyleNormal, \c StyleItalic, \c StyleOblique.
121 \endtable
122
123 \section1 Palette Configuration
124
125 The default \c palette can be configured for each style using the
126 \c Palette sub-group in the configuration file. The \c Palette sub-group can be
127 defined in two alternative ways:
128
129 \code
130 [Fusion]
131 Palette\Window=#dedede
132 Palette\WindowText=#212121
133 \endcode
134
135 See \l [QtQuick]{Palette} QML type for more information.
136
137 \section1 Using the Configuration File in a Project
138
139 In order to make it possible for Qt Quick Controls to find the configuration file,
140 it must be built into application's resources using the \l {The Qt Resource System}.
141 Here's an example \c .qrc file:
142
143 \code
144 <!DOCTYPE RCC><RCC version="1.0">
145 <qresource prefix="/">
146 <file>qtquickcontrols2.conf</file>
147 </qresource>
148 </RCC>
149 \endcode
150
151 \note Qt Quick Controls uses a file selector to load the configuration file. It
152 is possible to provide a different configuration file for different platforms and
153 locales. See \l QFileSelector documentation for more details.
154
155 Finally, the \c .qrc file must be listed in the application's build file.
156 For example:
157
158 \if defined(onlinedocs)
159 \tab {build-qt-app}{tab-cmake}{CMakeLists.txt (CMake)}{checked}
160 \tab {build-qt-app}{tab-qmake}{.pro (qmake)}{}
161 \tabcontent {tab-cmake}
162 \else
163 \section2 Using CMake
164 \endif
165 \badcode
166 set(CMAKE_AUTORCC ON)
167 qt_add_executable(my_app
168 application.qrc
169 main.cpp
170 ...
171 )
172 \endcode
173 \if defined(onlinedocs)
174 \endtabcontent
175 \tabcontent {tab-qmake}
176 \else
177 \section2 Using qmake
178 \endif
179 \badcode
180 RESOURCES = application.qrc
181 ...
182 \endcode
183 \if defined(onlinedocs)
184 \endtabcontent
185 \endif
186
187 See also: \l {Build System Integration}
188
189 \section1 Related Information
190
191 \list
192 \li \l{Styling Qt Quick Controls}
193 \li \l{Supported Environment Variables in Qt Quick Controls}
194 \endlist
195*/