ControlStyle QML Type
Define el estilo de un control en el estado normal. Más...
| Import Statement: | import Qt.labs.StyleKit |
| Inherits: | |
| Inherited By: |
Propiedades
- variations : list<StyleVariation>
Descripción detallada
Un ControlStyle describe el estilo que debe tener un Control. Su API refleja en gran medida la de un control Qt Quick: proporciona propiedades agrupadas para delegados como background, indicator, handle, y text, junto con propiedades de diseño como padding y spacing. Si está familiarizado con la API de un Control en Qt Quick Controls, debería encontrar la API de ControlStyle fácil de seguir.
ControlStyle hereda ControlStateStyle porque representa el estado normal: las propiedades establecidas directamente en un ControlStyle describen el aspecto del control cuando no hay ningún otro estado activo. Las modificaciones específicas de estado se establecen a través de estados anidados, como hovered pressed , y checked.
Each stylable control en un Style, Theme, o StyleVariation es un ControlStyle. Por ejemplo, en el siguiente fragmento, control, button y radioButton son todos ControlStyles:
Style { control { padding: 6 text { color: "white" } background { radius: 4 border.color: "gray" } indicator { implicitWidth: 20 implicitHeight: 20 border.width: 1 } handle { implicitWidth: 20 implicitHeight: 20 radius: 10 } } button { background { implicitWidth: 120 shadow.opacity: 0.6 shadow.verticalOffset: 2 shadow.horizontalOffset: 2 shadow.color: "gray" color: "lightsteelblue" gradient: Gradient { GradientStop { position: 0.0; color: Qt.alpha("black", 0.0)} GradientStop { position: 1.0; color: Qt.alpha("black", 0.2)} } } hovered { background.color: "lightslategrey" } pressed { background.scale: 0.95 } } radioButton { } checkBox { } slider { } // etc... }
Ver también All stylable controls, Style, Theme, StyleVariation, ControlStateStyle, y DelegateStyle.
Documentación de propiedades
variations : list<StyleVariation>
Una lista de type variations para este tipo de control.
Una variación de tipo proporciona un estilo alternativo para los controles que son hijos (o descendientes) de este tipo de control. Por ejemplo, puede utilizarla para dar un estilo diferente a todos los buttons dentro de un frame y a los botones en otros lugares:
Style { frame { variations: StyleVariation { button { text.color: "ghostwhite" background.border.width: 0 background.color: "slategrey" } } } groupBox { // groupBox falls back to frame. Therefore, if the varations set on a // frame is not wanted on a groupBox, just override it and set it back to []. variations: [] } }
A diferencia de las variaciones de instancia -que se aplican a instancias de control específicas desde la aplicación a través de la propiedad adjunta StyleVariation::variations - las variaciones de tipo se aplican a todas las instancias de un tipo de control desde Style, sin necesidad de que la aplicación opte por ello.
Véase también StyleVariation.
© 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.