On this page

Imagine Style

The Imagine Style is based on configurable image assets. More...

Import Statement: import QtQuick.Controls.Imagine
Since: Qt 5.10

Attached Properties

Detailed Description

The Imagine style is based on image assets. The style comes with a default set of images, but the images can be easily changed by providing a directory with images using a predefined naming convention.

Gallery of controls in Imagine style

The Imagine style with the default images

To run an application with the Imagine style, see Using Styles in Qt Quick Controls.

File Names

The image files are named using the following convention:

<control>-<element>-<states>

The <control> and <element> sections are mandatory, but the <states> section is optional. For example, if a single file named "button-background.9.png" is provided for Button, it will be used for every state that Button supports. It is up to the developer to decide the set of states that they will provide images for. However, it is recommended to provide images for the most common control states where possible, such as disabled, pressed, etc. This will ensure that interactive controls visually behave as the end user would expect them to.

Element Reference

The following table lists which elements are supported for each control, along with the possible states for that element, and the file extension that it expects. An element is an image that represents a certain visual part of the control. For example, Button's "background" element represents its background.

ControlElementStatesExtension
ApplicationWindowbackgroundactive.9.png (or .png)
BusyIndicatoranimationdisabled, running, mirrored, hovered.webp
backgroundsame as above.webp
Buttonbackgrounddisabled, pressed, checked, checkable, focused, highlighted, flat, mirrored, hovered.9.png
CheckBoxbackgrounddisabled, pressed, checked, partially-checked, focused, mirrored, hovered.9.png (or .png)
indicatorsame as above.png
CheckDelegatebackgrounddisabled, pressed, checked, partially-checked, focused, highlighted, mirrored, hovered.9.png (or .png)
indicatorsame as above.png
ComboBoxbackgrounddisabled, pressed, editable, open, focused, mirrored, hovered, flat.9.png (or .png)
indicatorsame as above.png
popupsame as above.9.png (or .png)
DelayButtonbackgrounddisabled, pressed, checked, checkable, focused, mirrored, hovered.9.png (or .png)
progresssame as above.9.png (or .png)
masksame as above.9.png (or .png)
Dialbackground1disabled, pressed, focused, mirrored, hovered.9.png (or .png)
handlesame as above.9.png (or .png)
Dialogbackgroundmodal, dim.9.png (or .png)
titlesame as above.9.png (or .png)
overlaymodal.9.png (or .png)
DialogButtonBoxbackgrounddisabled, mirrored.9.png (or .png)
Drawerbackgroundmodal, dim, top, left, right, bottom.9.png (or .png)
overlaymodal.9.png (or .png)
Framebackgrounddisabled, mirrored.9.png (or .png)
GroupBoxbackgrounddisabled, mirrored.9.png (or .png)
titlesame as above.9.png (or .png)
ItemDelegatebackgrounddisabled, pressed, focused, highlighted, mirrored, hovered.9.png (or .png)
Labelbackgrounddisabled, mirrored, hovered.9.png (or .png)
Menubackgroundmodal, dim.9.png (or .png)
overlaymodal.9.png (or .png)
MenuItemarrowdisabled, pressed, checked, focused, highlighted, mirrored, hovered.png
backgroundsame as above.9.png (or .png)
indicatorsame as above.png
MenuSeparatorbackgrounddisabled, mirrored.9.png (or .png)
separatorsame as above.9.png (or .png)
Pagebackgrounddisabled, mirrored.9.png (or .png)
PageIndicatorbackgrounddisabled, mirrored, hovered.9.png (or .png)
delegatedisabled, pressed, current, mirrored, hovered.png
Panebackgrounddisabled, mirrored.9.png (or .png)
Popupbackgroundmodal, dim.9.png (or .png)
overlaymodal.9.png (or .png)
ProgressBaranimationdisabled, mirrored, hovered.png
backgrounddisabled, indeterminate, mirrored, hovered.9.png (or .png)
masksame as above.9.png (or .png)
progresssame as above.9.png (or .png)
RadioButtonbackgrounddisabled, pressed, checked, focused, mirrored, hovered.9.png (or .png)
indicatorsame as above.png
RadioDelegatebackgrounddisabled, pressed, checked, focused, highlighted, mirrored, hovered.9.png (or .png)
indicatorsame as above.png
RangeSliderbackgroundvertical, horizontal, disabled, focused, mirrored, hovered.9.png (or .png)
RangeSliderprogresssame as above.9.png (or .png)
handlefirst, second, vertical, horizontal, disabled, pressed, focused, mirrored, hovered.png
RoundButtonbackgrounddisabled, pressed, checked, checkable, focused, highlighted, flat, mirrored, hovered.9.png (or .png)
ScrollBarbackgroundvertical, horizontal, disabled, interactive, pressed, mirrored, hovered.9.png (or .png)
handlesame as above.9.png (or .png)
ScrollIndicatorbackgroundvertical, horizontal, disabled, mirrored, hovered.9.png (or .png)
handlesame as above.9.png (or .png)
ScrollViewbackgrounddisabled, mirrored.9.png (or .png)
Sliderbackgroundvertical, horizontal, disabled, pressed, focused, mirrored, hovered.9.png (or .png)
handlesame as above.9.png (or .png)
progresssame as above.9.png (or .png)
SpinBoxbackgrounddisabled, editable, focused, mirrored, hovered.9.png (or .png)
editordisabled, focused, mirrored, hovered.9.png (or .png)
indicatorup, down, disabled, editable, pressed, focused, mirrored, hovered.9.png (or .png)
StackViewbackgrounddisabled, mirrored.9.png (or .png)
SwipeDelegatebackgrounddisabled, pressed, focused, highlighted, mirrored, hovered.9.png (or .png)
SwipeViewbackgroundvertical, horizontal, disabled, interactive, focused, mirrored.9.png (or .png)
Switchbackgrounddisabled, pressed, checked, focused, mirrored, hovered.9.png (or .png)
handlesame as above.9.png (or .png)
indicatorsame as above.9.png (or .png)
SwitchDelegatebackgrounddisabled, pressed, checked, focused, highlighted, mirrored, hovered.9.png (or .png)
handlesame as above.9.png (or .png)
indicatorsame as above.9.png (or .png)
TabBarbackgrounddisabled, header, footer, mirrored.9.png (or .png)
TabButtonbackgrounddisabled, pressed, checked, focused, mirrored, hovered.9.png (or .png)
TextAreabackgrounddisabled, focused, mirrored, hovered.9.png (or .png)
TextFieldbackgrounddisabled, focused, mirrored, hovered.9.png (or .png)
ToolBarbackgrounddisabled, header, footer, mirrored.9.png (or .png)
ToolButtonbackgrounddisabled, pressed, checked, checkable, focused, highlighted, flat, mirrored, hovered.9.png (or .png)
ToolSeparatorbackgroundvertical, horizontal, disabled, mirrored.9.png (or .png)
separatorsame as above.9.png (or .png)
ToolTipbackground.9.png (or .png)
Tumblerbackgrounddisabled, focused, mirrored, hovered.9.png (or .png)

Note: 1) The Imagine style Dial does not yet support the startAngle and endAngle properties that were introduced in Qt 6.6, and instead uses a fixed background image.

Asset Examples

The following table lists examples of assets (taken from the default Imagine style assets) for all controls. The list is not exhaustive, as not all elements need assets, but it can be used as a guide when creating your own assets.

The template that these assets were exported from is available as a Sketch project.

ControlElementStatesAssetNotes
ApplicationWindowbackground

ApplicationWindow background asset

See footnote 1
overlay

ApplicationWindow overlay asset

See footnote 1
overlaymodal

ApplicationWindow overlay modal asset

See footnote 1
Buttonbackground

Button background asset

backgrounddisabled

Button background disabled asset

backgroundfocused

Button background focused asset

backgroundpressed

Button background pressed asset

backgroundchecked

Button background checked asset

backgroundchecked, disabled

Button background checked disabled asset

backgroundchecked, focused

Button background checked focused asset

backgroundchecked, hovered

Button background checked hovered asset

backgroundhighlighted

Button background highlighted asset

backgroundhighlighted, disabled

Button background highlighted disabled asset

backgroundhighlighted, focused

Button background highlighted focused asset

backgroundhighlighted, hovered

Button background highlighted hovered asset

backgroundhighlighted, pressed

Button background highlighted pressed asset

backgroundhighlighted, checked

Button background highlighted checked asset

backgroundhovered

Button background hovered asset

backgroundflat

Button background flat asset

backgroundflat, disabled

Button background flat disabled asset

backgroundflat, hovered

Button background flat hovered asset

backgroundflat, pressed

Button background flat pressed asset

backgroundflat, checked

Button background flat checked asset

CheckBoxindicator

CheckBox indicator asset

indicatordisabled

CheckBox indicator disabled asset

indicatorpressed

CheckBox indicator pressed asset

indicatorchecked

CheckBox indicator checked asset

indicatorchecked, pressed

CheckBox indicator checked pressed asset

indicatorchecked, hovered

CheckBox indicator checked hovered asset

indicatorchecked, focused

CheckBox indicator checked focused asset

indicatorpartially, checked

CheckBox indicator partially checked asset

indicatorpartially, checked, pressed

CheckBox indicator partially checked pressed asset

indicatorpartially, checked, focused

CheckBox indicator partially checked focused asset

indicatorpartially, checked, hovered

CheckBox indicator partially checked hovered asset

indicatorfocused

CheckBox indicator focused asset

indicatorhovered

CheckBox indicator hovered asset

CheckDelegatebackground

CheckDelegate background asset

backgrounddisabled

CheckDelegate background disabled asset

backgroundpressed

CheckDelegate background pressed asset

backgroundfocused

CheckDelegate background focused asset

backgroundhovered

CheckDelegate background hovered asset

indicator

CheckDelegate indicator asset

indicatordisabled

CheckDelegate indicator disabled asset

indicatorpressed

CheckDelegate indicator pressed asset

indicatorchecked

CheckDelegate indicator checked asset

indicatorchecked, pressed

CheckDelegate indicator checked pressed asset

indicatorchecked, focused

CheckDelegate indicator checked focused asset

indicatorchecked, hovered

CheckDelegate indicator checked hovered asset

indicatorfocused

CheckDelegate indicator focused asset

indicatorhovered

CheckDelegate indicator hovered asset

indicatorpartially, checked

CheckDelegate indicator partial checked asset

indicatorpartially, checked, pressed

CheckDelegate indicator partial checked pressed asset

indicatorpartially, checked, focused

CheckDelegate indicator partial checked focused asset

indicatorpartially, checked, hovered

CheckDelegate indicator partial checked hovered asset

indicatorhovered

CheckDelegate indicator hovered asset

ComboBoxbackground

ComboBox background asset

backgrounddisabled

ComboBox background disabled asset

backgroundfocused

ComboBox background focused asset

backgroundhovered

ComboBox background hovered asset

backgroundpressed

ComboBox background pressed asset

backgroundopen

ComboBox background open asset

backgroundeditable

ComboBox background editable asset

backgroundeditable, focused

ComboBox background editable focused asset

backgroundeditable, disabled

ComboBox background editable disabled asset

indicator

ComboBox indicator asset

indicatordisabled

ComboBox indicator disabled asset

indicatoreditable

ComboBox indicator editable asset

indicatoreditable, disabled

ComboBox indicator editable disabled asset

indicatoreditable, mirrored

ComboBox indicator editable mirrored asset

indicatoreditable, mirrored, disabled

ComboBox indicator editable mirrored disabled asset

popup

ComboBox popup asset

DelayButtonbackground

DelayButton background asset

backgrounddisabled

DelayButton background disabled asset

backgrounddisabled, checked

DelayButton background disabled checked asset

backgroundfocused

DelayButton background focused asset

backgroundpressed

DelayButton background pressed asset

backgroundchecked

DelayButton background checked asset

backgroundchecked, focused

DelayButton background checked focused asset

backgroundchecked, hovered

DelayButton background checked hovered asset

backgroundhovered

DelayButton background hovered asset

progress

DelayButton progress asset

progressdisabled

DelayButton progress disabled asset

mask

DelayButton mask asset

Dialbackground

Dial background asset

backgrounddisabled

Dial background disabled asset

backgroundfocused

Dial background focused asset

handle

Dial handle asset

handledisabled

Dial handle disabled asset

handlefocused

Dial handle focused asset

handlefocused, pressed

Dial handle focused pressed asset

handlefocused, hovered

Dial handle focused hovered asset

handlepressed

Dial handle pressed asset

handlehovered

Dial handle hovered asset

Dialogbackground

Dialog background asset

overlay

Dialog overlay asset

See footnote 1
overlaymodal

Dialog overlay modal asset

See footnote 1
DialogButtonBoxbackground

DialogButtonBox background asset

Drawerbackgroundleft

Drawer background left asset

backgroundright

Drawer background right asset

backgroundtop

Drawer background top asset

backgroundbottom

Drawer background bottom asset

overlay

Drawer overlay asset

See footnote 1
overlaymodal

Drawer overlay modal asset

See footnote 1
Framebackground

Frame background asset

GroupBoxbackground

GroupBox background asset

title

GroupBox title asset

ItemDelegatebackground

ItemDelegate background asset

backgrounddisabled

ItemDelegate background disabled asset

backgroundpressed

ItemDelegate background pressed asset

backgroundfocused

ItemDelegate background focused asset

backgroundhovered

ItemDelegate background hovered asset

backgroundhighlighted

ItemDelegate background highlighted asset

Menubackground

Menu background asset

MenuItembackground

MenuItem background asset

backgroundhighlighted

MenuItem background highlighted asset

arrow

MenuItem arrow asset

arrowmirrored

MenuItem arrow mirrored asset

arrowdisabled

MenuItem arrow disabled asset

arrowmirrored, disabled

MenuItem arrow mirrored disabled asset

indicator

MenuItem indicator asset

indicatordisabled

MenuItem indicator disabled asset

indicatorpressed

MenuItem indicator pressed asset

indicatorchecked

MenuItem indicator checked asset

indicatorchecked, pressed

MenuItem indicator checked pressed asset

indicatorchecked, focused

MenuItem indicator checked focused asset

indicatorchecked, hovered

MenuItem indicator checked hovered asset

indicatorfocused

MenuItem indicator focused asset

indicatorhovered

MenuItem indicator hovered asset

MenuSeparatorseparator

MenuSeparator separator asset

Pagebackground

Page background asset

See footnote 1
PageIndicatordelegate

PageIndicator delegate asset

delegatedisabled

PageIndicator delegate disabled asset

delegatedisabled, current

PageIndicator delegate disabled current asset

delegatepressed

PageIndicator delegate pressed asset

delegatecurrent

PageIndicator delegate current asset

Panebackground

Pane background asset

Popupbackground

Popup background asset

See footnote 1
overlay

Popup overlay asset

See footnote 1
overlaymodal

Popup overlay modal asset

ProgressBarbackground

ProgressBar background asset

progress

ProgressBar progress asset

mask

ProgressBar mask asset

RadioButtonindicator

RadioButton indicator asset

indicatordisabled

RadioButton indicator disabled asset

indicatorpressed

RadioButton indicator pressed asset

indicatorchecked

RadioButton indicator checked asset

indicatorchecked, focused

RadioButton indicator checked focused asset

indicatorchecked, hovered

RadioButton indicator checked hovered asset

indicatorchecked, pressed

RadioButton indicator checked pressed asset

indicatorfocused

RadioButton indicator focused asset

indicatorhovered

RadioButton indicator hovered asset

RadioDelegatebackground

RadioDelegate background asset

backgrounddisabled

RadioDelegate background disabled asset

backgroundpressed

RadioDelegate background pressed asset

backgroundfocused

RadioDelegate background focused asset

backgroundhovered

RadioDelegate background hovered asset

indicator

RadioDelegate indicator asset

indicatordisabled

RadioDelegate indicator disabled asset

indicatorpressed

RadioDelegate indicator pressed asset

indicatorchecked

RadioDelegate indicator checked asset

indicatorchecked, focused

RadioDelegate indicator checked focused asset

indicatorchecked, hovered

RadioDelegate indicator checked hovered asset

indicatorchecked, pressed

RadioDelegate indicator checked pressed asset

indicatorfocused

RadioDelegate indicator focused asset

indicatorhovered

RadioDelegate indicator hovered asset

RangeSliderbackgroundvertical

RangeSlider background vertical asset

backgroundhorizontal

RangeSlider background horizontal asset

progressvertical

RangeSlider progress vertical asset

progressvertical, disabled

RangeSlider progress vertical disabled asset

progresshorizontal

RangeSlider progress horizontal asset

progresshorizontal, disabled

RangeSlider progress horizontal disabled asset

handle

RangeSlider handle asset

handledisabled

RangeSlider handle disabled asset

handlefocused

RangeSlider handle focused asset

handlefocused, hovered

RangeSlider handle focused hovered asset

handlefocused, pressed

RangeSlider handle focused pressed asset

handlehovered

RangeSlider handle hovered asset

handlepressed

RangeSlider handle pressed asset

RoundButtonbackground

RoundButton background asset

backgrounddisabled

RoundButton background disabled asset

backgrounddisabled, checked

RoundButton background disabled checked asset

backgroundfocused

RoundButton background focused asset

backgroundpressed

RoundButton background pressed asset

backgroundchecked

RoundButton background checked asset

backgroundchecked, focused

RoundButton background checked focused asset

backgroundchecked, hovered

RoundButton background checked hovered asset

backgroundhighlighted

RoundButton background highlighted asset

backgroundhighlighted, pressed

RoundButton background highlighted pressed asset

backgroundhighlighted, focused

RoundButton background highlighted focused asset

backgroundhighlighted, hovered

RoundButton background highlighted hovered asset

backgroundhovered

RoundButton background hovered asset

ScrollBarhandle

ScrollBar handle asset

handledisabled

ScrollBar handle disabled asset

handleinteractive

ScrollBar handle interactive asset

handleinteractive, disabled

ScrollBar handle interactive disabled asset

handleinteractive, pressed

ScrollBar handle interactive pressed asset

handleinteractive, hovered

ScrollBar handle interactive hovered asset

ScrollIndicatorhandle

ScrollIndicator handle asset

Sliderbackgroundvertical

Slider background vertical asset

backgroundhorizontal

Slider background horizontal asset

progressvertical

Slider progress vertical asset

progressvertical, disabled

Slider progress vertical disabled asset

progresshorizontal

Slider progress horizontal asset

progresshorizontal, disabled

Slider progress horizontal disabled asset

handle

Slider handle asset

handledisabled

Slider handle disabled asset

handlefocused

Slider handle focused asset

handlefocused, hovered

Slider handle focused hovered asset

handlefocused, pressed

Slider handle focused pressed asset

handlehovered

Slider handle hovered asset

handlepressed

Slider handle pressed asset

SpinBoxbackground

SpinBox background asset

backgrounddisabled

SpinBox background disabled asset

backgroundfocused

SpinBox background focused asset

backgroundeditable

SpinBox background editable asset

indicatorup

SpinBox indicator up asset

indicatorup, disabled

SpinBox indicator up disabled asset

indicatorup, pressed

SpinBox indicator up pressed asset

indicatorup, focused

SpinBox indicator up focused asset

indicatorup, mirrored

SpinBox indicator up mirrored asset

indicatorup, hovered

SpinBox indicator up hovered asset

indicatorup, editable

SpinBox indicator up editable asset

indicatorup, editable, pressed

SpinBox indicator up editable pressed asset

indicatorup, editable, focused

SpinBox indicator up editable focused asset

indicatorup, editable, mirrored

SpinBox indicator up editable mirrored asset

indicatorup, editable, hovered

SpinBox indicator up editable hovered asset

indicatordown

SpinBox indicator down asset

indicatordown, disabled

SpinBox indicator down disabled asset

indicatordown, pressed

SpinBox indicator down pressed asset

indicatordown, focused

SpinBox indicator down focused asset

indicatordown, mirrored

SpinBox indicator down mirrored asset

indicatordown, hovered

SpinBox indicator down hovered asset

indicatordown, editable

SpinBox indicator down editable asset

indicatordown, editable, pressed

SpinBox indicator down editable pressed asset

indicatordown, editable, focused

SpinBox indicator down editable focused asset

indicatordown, editable, mirrored

SpinBox indicator down editable mirrored asset

indicatordown, editable, hovered

SpinBox indicator down editable hovered asset

SwipeDelegatebackground

SwipeDelegate background asset

backgrounddisabled

SwipeDelegate background disabled asset

backgroundpressed

SwipeDelegate background pressed asset

backgroundfocused

SwipeDelegate background focused asset

backgroundhovered

SwipeDelegate background hovered asset

Switchindicator

Switch indicator asset

indicatordisabled

Switch indicator disabled asset

indicatorpressed

Switch indicator pressed asset

indicatorchecked

Switch indicator checked asset

indicatorchecked, focused

Switch indicator checked focused asset

indicatorchecked, hovered

Switch indicator checked hovered asset

indicatorchecked, pressed

Switch indicator checked pressed asset

indicatorfocused

Switch indicator focused asset

indicatorhovered

Switch indicator hovered asset

handle

Switch handle asset

handledisabled

Switch handle disabled asset

handlepressed

Switch handle pressed asset

SwitchDelegatebackground

SwitchDelegate background asset

backgrounddisabled

SwitchDelegate background disabled asset

backgroundpressed

SwitchDelegate background pressed asset

backgroundfocused

SwitchDelegate background focused asset

backgroundhovered

SwitchDelegate background hovered asset

indicator

SwitchDelegate indicator asset

indicatordisabled

SwitchDelegate indicator disabled asset

indicatorpressed

SwitchDelegate indicator pressed asset

indicatorchecked

SwitchDelegate indicator checked asset

indicatorchecked, focused

SwitchDelegate indicator checked focused asset

indicatorchecked, hovered

SwitchDelegate indicator checked hovered asset

indicatorchecked, pressed

SwitchDelegate indicator checked pressed asset

indicatorfocused

SwitchDelegate indicator focused asset

indicatorhovered

SwitchDelegate indicator hovered asset

handle

SwitchDelegate handle asset

handledisabled

SwitchDelegate handle disabled asset

TabBarbackground

TabBar background asset

TabButtonbackground

TabButton background asset

backgrounddisabled

TabButton background disabled asset

backgroundpressed

TabButton background pressed asset

backgroundchecked

TabButton background checked asset

backgroundhovered

TabButton background hovered asset

backgrounddisabled, checked

TabButton background disabled checked asset

TextAreabackground

TextArea background asset

backgrounddisabled

TextArea background disabled asset

backgroundfocused

TextArea background focused asset

TextFieldbackground

TextField background asset

backgrounddisabled

TextField background disabled asset

backgroundfocused

TextField background focused asset

ToolBarbackground

ToolBar background asset

ToolButtonbackground

ToolButton background asset

backgrounddisabled, checked

ToolButton background disabled checked asset

backgroundfocused

ToolButton background focused asset

backgroundpressed

ToolButton background pressed asset

backgroundchecked

ToolButton background checked asset

backgroundchecked, focused

ToolButton background checked focused asset

backgroundchecked, hovered

ToolButton background checked hovered asset

backgroundhovered

ToolButton background hovered asset

ToolSeparatorseparatorhorizontal

ToolSeparator separator horizontal asset

separatorvertical

ToolSeparator separator vertical asset

ToolTipbackground

ToolTip background asset

1 A 1x1 image containing one color, stretched to fill the control.

9-Patch Images

The Imagine style uses 9-patch images in order to give designers control over how a particular element responds to being resized. Here is an example of a 9-patch image that represents a Button's background, alongside a magnified version (to make it easier to see the 9-patch lines):

Button background 9-patch image showing stretch and padding lines

The content of the image is 44 pixels wide by 32 pixels high. Every 9-patch image needs a one pixel thick line (collectively referred to as "9-patch lines") around every side, so the actual size of the image becomes 46 pixels wide by 34 pixels high. Note that the 9-patch lines must be one pixel thick regardless of the target DPI of the image. For example, the 9-patch lines for button-background.9.png and button-background@2x.9.png must both be one pixel thick.

The 9-patch lines must be black, and the remaining areas must be transparent or white:

Diagram showing 9-patch line color requirements

Stretchable Areas

The 9-patch lines on the top and left edges determine which parts of the image are stretched when it is resized.

Below are examples of the 9-patch image being resized to one and a half times its original size in various dimensions:

Examples of 9-patch image resized showing stretchable areas

Notice how the the rounded corners keep their original size, as they are outside the range of the lines.

Padding Areas

The 9-patch lines on the right and bottom edges determine how much space is available for the control's contentItem, which means it can also be thought of as controlling the padding. For a diagram that illustrates padding, see Control Layout.

Below are more examples of the 9-patch image being resized, but this time demonstrating how the padding 9-patch lines work.

Examples of 9-patch image resized showing padding areas

The contentItem can take up as much space as it needs within the shaded areas. If the padding lines are left out, the contentItem will take as much space as it needs without exceeding the stretchable areas.

Inset Areas

In some cases it is necessary for a control to have a drop shadow, for example. However, if we were to add a drop shadow to the button above, it would affect its size, which presents problems for both layouting and mouse/touch input boundaries.

Inset areas accounts for this by telling the control that a certain area of the 9-patch image should go outside of the control:

Diagram showing 9-patch inset lines for drop shadow

In the image below, the dashed line represents the button's clickable area, as well as the space that it will take up in a layout. The shadow is marked by the striped area behind it:

Button with drop shadow showing clickable area and insets

Exporting 9-Patch Images

Various vector and bitmap editors can be used to create 9-patch images suitable for use with the Imagine style. The following sections briefly explain the export process for each editor, and the last section explains how to ensure the exported images are 9-patch-conformant.

Affinity Designer

See Affinity's Export Settings documentation.

Adobe Illustrator

See Adobe's Asset Export panel documentation.

Adobe Photoshop

See Adobe's Generate image assets from layers documentation.

Inkscape

The Inkscape 9-Patch Export Extension can be used to export assets with Inkscape.

Sketch

See Sketch's Exporting documentation.

Qt Quick Controls also provides a plugin for Sketch that automatically fixes the thickness of the 9-patch lines after the assets are exported. To install this file, double-click on it. Once Sketch has confirmed that the 9-patch export plugin has been installed, the plugin will automatically process images when they are exported.

Fixing 9-Patch Lines

When exporting 9-patch images in several DPI variants (@2x, @3x, etc.), the 9-patch lines will typically be scaled up along with the image. There are several ways to fix this, but perhaps the simplest approach is to use ImageMagick's mogrify tool. The tool has a -shave feature that can be used to crop the image to reduce the thickness of the 9-patch lines:

mogrify -shave 1x1 -path path/to/images *@2x.9.png
mogrify -shave 2x2 -path path/to/images *@3x.9.png
mogrify -shave 3x3 -path path/to/images *@4x.9.png

Regular DPI images (those without the @Nx prefix) are not affected, so it is only necessary to run the command on images intended for high DPI displays.

Animated Images

The WebP and GIF animated image formats are supported by the Imagine style.

Customization

Path

The Imagine style allows customizing the path that is used to do the image asset selection. The path can be specified for any window or item, and it automatically propagates to children in the same manner as fonts. In the following example, the window and all three radio buttons appear with dark image assets (files that are located in "qrc:/themes/dark").

import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Imagine

ApplicationWindow {
    visible: true

    Imagine.path: "qrc:/themes/dark"

    Column {
        anchors.centerIn: parent

        RadioButton { text: qsTr("Small") }
        RadioButton { text: qsTr("Medium"); checked: true }
        RadioButton { text: qsTr("Large") }
    }
}

Small, Medium, Large radio buttons in Imagine dark theme

In addition to specifying the path in QML, it is also possible to specify it via an environment variable or in a configuration file. Attributes specified in QML take precedence over all other methods.

Configuration File
VariableDescription
PathSpecifies 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:

[Imagine]
Path=:/imagine-assets

To specify a relative path to a local directory:

[Imagine]
Path=imagine-assets

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

See Qt Quick Controls Configuration File for more details about the configuration file.

Environment Variables
VariableDescription
QT_QUICK_CONTROLS_IMAGINE_PATHSpecifies 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:

QT_QUICK_CONTROLS_IMAGINE_PATH=:/imagine-assets

To specify a relative path to a local directory:

QT_QUICK_CONTROLS_IMAGINE_PATH=imagine-assets

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

QT_QUICK_CONTROLS_IMAGINE_SMOOTHSet to 1 to enable smooth scaling for 9-patch images. This environment variable was added in Qt 6.5.

See Supported Environment Variables in Qt Quick Controls for the full list of supported environment variables.

Palette

The Imagine style supports palette customization via the palette property and the qtquickcontrols2.conf file. As with other styles, the exact palette roles that the Imagine style uses are style-dependent. However, as most of the visual appearance of controls (for example: backgrounds) are managed through image assets, only the roles that are typically used for text will have an effect.

Font

Custom fonts can be set via the font property and the configuration file.

Dependency

The Imagine style must be separately imported to gain access to the attributes that are specific to the Imagine style. It should be noted that regardless of the references to the Imagine style, the same application code runs with any other style. Imagine-specific attributes only have an effect when the application is run with the Imagine style.

If the Imagine style is imported in a QML file that is always loaded, the Imagine style must be deployed with the application in order to be able to run the application regardless of which style the application is run with. By using file selectors, style-specific tweaks can be applied without creating a hard dependency to a style.

See also Styling Qt Quick Controls

Attached Property Documentation

Imagine.path : string

This attached property holds the path to the image assets...

Button {
    Imagine.path: "qrc:/themes/dark"
}

© 2025 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.