1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
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
10 Qt Quick Controls support a special configuration file, \c qtquickcontrols2.conf,
11 which is built into an application's resources.
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.
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.
38 \section1 Controls Section
40 The following values can be specified in a \c Controls section of the
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}.
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.
59 \section1 Imagine Section
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:
64 \include qquickimaginestyle.qdocinc conf
66 \section1 Material Section
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:
71 \include qquickmaterialstyle.qdocinc conf
73 \section1 Universal Section
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:
78 \include qquickuniversalstyle.qdocinc conf
80 \section1 Font Configuration
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:
96 Supported font attributes:
103 \li The \l {QFont::family}{font family}.
106 \li The \l {QFont::pointSizeF}{point size}.
109 \li The \l {QFont::pixelSize}{pixel size}.
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.
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),
124 \li The \l {QFont::}{style}.
125 Available values: \c StyleNormal, \c StyleItalic, \c StyleOblique.
128 \section1 Palette Configuration
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:
136 Palette\Window=#dedede
137 Palette\WindowText=#212121
147 See \l [QtQuick]{Palette} QML type for more information.
149 \section1 Using the Configuration File in a Project
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:
156 <!DOCTYPE RCC><RCC version="1.0">
157 <qresource prefix="/">
158 <file>qtquickcontrols2.conf</file>
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.
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:
171 RESOURCES = application.qrc
174 \section1 Related Information
177 \li \l{Styling Qt Quick Controls}
178 \li \l{Supported Environment Variables in Qt Quick Controls}