Qt Quick Controls 2 Configuration File

Qt Quick Controls 2 support a special configuration file, :/qtquickcontrols2.conf, that is built into an application's resources.

The configuration file can specify the preferred style and certain style-specific attributes. The following example specifies that the preferred style is the Material style. Furthermore, when the application is run with the Material style, its theme is light and the accent and primary colors are teal and blue grey, respectively. However, if the application is run with the Universal style instead, the accent color is red and the appropriate theme is chosen based on the system theme colors.

[Controls]
Style=Material

[Universal]
Theme=System
Accent=Red

[Material]
Theme=Light
Accent=Teal
Primary=BlueGrey

Material style specific values that can be specified in a Material section of the configuration file:

VariableDescription
ThemeSpecifies the default Material theme. The value can be one of the available themes, for example "Dark".
AccentSpecifies the default Material accent color. The value can be any color, but it is recommended to use one of the pre-defined Material colors, for example "Teal".
PrimarySpecifies the default Material primary color. The value can be any color, but it is recommended to use one of the pre-defined Material colors, for example "BlueGrey".
ForegroundSpecifies the default Material foreground color. The value can be any color, or one of the pre-defined Material colors, for example "Brown".
BackgroundSpecifies the default Material background color. The value can be any color, or one of the pre-defined Material colors, for example "Grey".

Universal style specific values that can be specified in a Universal section of the configuration file:

VariableDescription
ThemeSpecifies the default Universal theme. The value can be one of the available themes, for example "Dark".
AccentSpecifies the default Universal accent color. The value can be any color, but it is recommended to use one of the pre-defined Universal colors, for example "Violet".
ForegroundSpecifies the default Universal foreground color. The value can be any color, or one of the pre-defined Universal colors, for example "Brown".
BackgroundSpecifies the default Universal background color. The value can be any color, or one of the pre-defined Universal colors, for example "Steel".

In order to make it possible for Qt Quick Controls 2 to find the configuration file, it must be built into application's resources using the The Qt Resource System. Here's an example .qrc file:

<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
    <file>qtquickcontrols2.conf</file>
</qresource>
</RCC>

Note: Qt Quick Controls 2 uses a file selector to load the configuration file. It is possible to provide a different configuration file for different platforms and locales. See QFileSelector documentation for more details.

Finally, the .qrc file must be listed in the application's .pro file so that the build system knows about it. For example:

RESOURCES = application.qrc

© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.