StyleReader QML Type
Reads properties from the active Style for a specific control. More...
| Import Statement: | import Qt.labs.StyleKit |
| Inherits: |
Properties
- checked : bool
- controlType : enumeration
- enabled : bool
- focused : bool
- font : font
- global : ControlStyleProperties
- highlighted : bool
- hovered : bool
- palette : palette
- pressed : bool
- vertical : bool
Detailed Description
StyleReader is the bridge between a control in Qt Quick Controls and the active style. It exposes all the style properties — backgrounds, indicators, handles, text, padding, and more — that a control, and its delegates, should bind to. All built-in StyleKit controls use a StyleReader internally for this purpose.
The state properties — hovered, pressed, focused, checked, highlighted, etc. — tell StyleReader which state the control is in. It uses these to resolve and read the correct property values from the Style, taking Themes, StyleVariations, fallback types, and property propagation into account.
When implementing a CustomControl, you can follow the same approach as the built-in controls:
// Main.qml component CustomButton : Rectangle { StyleReader { id: styleReader controlType: StyleReader.Button hovered: hoverHandler.hovered pressed: tapHandler.pressed palette: app.palette } implicitWidth: styleReader.background.implicitWidth implicitHeight: styleReader.background.implicitHeight color: styleReader.background.color radius: styleReader.background.radius HoverHandler { id: hoverHandler } TapHandler { id: tapHandler } Text { font: styleReader.font anchors.centerIn: parent text: "ok" } }
Note: The style properties inherited from ControlStyleProperties do not map directly to the Style. Instead, they reflect a cache of potentially interpolated values during an active transition. Writing to them will not update the corresponding properties in the Style and may interfere with ongoing transitions. Write directly to the Style when you need to change a style property.
Note: Types in Qt.labs modules are not guaranteed to remain compatible in future versions.
See also CustomControl, Style, and StyleVariation.controlType.
Property Documentation
checked : bool
Whether the control is checked.
Bind this to the control's checked property.
The default value is false.
See also ControlStateStyle.checked.
controlType : enumeration
Identifies which control type in the Style this reader reads properties from. This can either be set to one of the predefined values below, or to a custom control type defined in the Style.
| Constant | Description |
|---|---|
StyleReader.Button | Button |
StyleReader.CheckBox | CheckBox |
StyleReader.ComboBox | ComboBox |
StyleReader.Frame | Frame |
StyleReader.GroupBox | GroupBox |
StyleReader.ItemDelegate | ItemDelegate |
StyleReader.Label | Label |
StyleReader.Menu | Menu |
StyleReader.Dialog | Dialog |
StyleReader.Page | Page |
StyleReader.Pane | Pane |
StyleReader.Popup | Popup |
StyleReader.ProgressBar | ProgressBar |
StyleReader.RadioButton | RadioButton |
StyleReader.ScrollBar | ScrollBar |
StyleReader.ScrollView | ScrollView |
StyleReader.SearchField | SearchField |
StyleReader.Slider | Slider |
StyleReader.SpinBox | SpinBox |
StyleReader.Switch | Switch |
StyleReader.TabBar | TabBar |
StyleReader.TabButton | TabButton |
StyleReader.TextArea | TextArea |
StyleReader.TextField | TextField |
StyleReader.ToolBar | ToolBar |
StyleReader.ToolButton | ToolButton |
StyleReader.ToolSeparator | ToolSeparator |
See also StyleVariation.controlType.
enabled : bool
Whether the control is enabled.
Bind this to the control's enabled property.
The default value is true.
See also ControlStyleState.disabled.
focused : bool
Whether the control has active focus.
Bind this to the control's activeFocus property.
The default value is false.
See also ControlStateStyle.focused.
font : font [read-only]
The effective font for this control type, as defined by the style. This also takes into account any font overrides set in the text properties of the style.
Bind the control's font property to this property.
Note: Unlike properties such as hovered, pressed and palette — which is forwarded from the control to the StyleReader — font is an output. Bind the control's font property to this value, not the other way around.
global : ControlStyleProperties [read-only]
Provides direct access to the style properties, bypassing any ongoing transition.
While a state transition is ongoing, style properties read from a StyleReader may return interpolated values. By prepending global to the property path, you bypass the transition and get the end-state values immediately.
For example, when transitioning from hovered to pressed, background.color may return an interpolated value between the color in the hovered state and the color in the pressed state. global.background.color, on the other hand, returns the color in the pressed state directly.
See also transitionsEnabled.
highlighted : bool
Whether the control is highlighted.
Bind this to the control's highlighted property.
The default value is false.
See also ControlStateStyle.highlighted.
hovered : bool
Whether the control is hovered.
Bind this to the control's hovered property.
The default value is false.
See also ControlStateStyle.hovered.
palette : palette
The palette of the control. StyleKit uses this to resolve color properties that bind the palette in the Style.
Bind this to the control's palette property.
See also Style.palette.
pressed : bool
Whether the control is pressed.
Bind this to the control's pressed property.
The default value is false.
See also ControlStateStyle.pressed.
vertical : bool
Whether the control is oriented vertically.
Bind this to the control's orientation.
The default value is false.
See also ControlStateStyle.vertical.
© 2026 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.