Qt Quick Controls Configuration File

Qt Quick Controls support a special configuration file, qtquickcontrols2.conf, which 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.

 
Sélectionnez
[Controls]
Style=Material

[Universal]
Theme=System
Accent=Red

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

It is possible to specify a custom location for the configuration file with the QT_QUICK_CONTROLS_CONF environment variable.

Controls Section

The following values can be specified in a Controls section of the configuration file:

Variable

Description

Style

Specifies the style to run the application with. The value can be the name of one of the built-in styles or a custom style.

FallbackStyle

Specifies the style to use for controls that are not implemented. The style must be one of the built-in styles. By default, the Default style is used.

Imagine Section

The following table lists values that can be used to configure the Imagine style in an Imagine section of the configuration file:

Variable

Description

Path

Specifies the path to the directory that contains the Imagine style assets. If not specified, the built-in assets are used.

For example, to specify a path to a directory stored in the resource system:

 
Sélectionnez
[Imagine]
Path=:/imagine-assets

To specify a relative path to a local directory:

 
Sélectionnez
[Imagine]
Path=imagine-assets

Due to a technical limitation, the path should not be named "imagine" if it is relative to the qtquickcontrols2.conf file.

Material Section

The following table lists values that can be used to configure the Material style in a Material section of the configuration file:

Variable

Description

Theme

Specifies the default Material theme. The value can be one of the available themes, for example "Dark".

Variant

Specifies the Material variant. The Material Design has two variants: a normal variant designed for touch devices, and a dense variant for desktop. The dense variant uses smaller sizes for controls and their fonts.

The value can be "Normal" or "Dense".

Accent