En esta página

ControlStyle QML Type

Define el estilo de un control en el estado « normal ». Más información...

Import Statement: import Qt.labs.StyleKit
Inherits:

ControlStateStyle

Inherited By:

CustomControl

Status: Technology preview

Este tipo se encuentra en fase de vista previa tecnológica y está sujeto a cambios.

Propiedades

Descripción detallada

Un ControlStyle describe cómo debe configurarse el estilo de un Control. Su API se asemeja en gran medida a 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ás familiarizado con la API de un Control en los controles Qt Quick, te resultará fácil seguir la API de ControlStyle.

ControlStyle hereda de ` 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 cada estado se establecen mediante estados anidados, como ` hovered `, ` pressed` y ` checked`.

Each stylable control En un ` Style`, ` Theme` o ` StyleVariation `, un `ControlStyle` es un estilo de control. Por ejemplo, en el fragmento de código siguiente, ` control`, ` button ` y ` radioButton ` son todos estilos de control:

Style {
    control {
        padding: 6
        text {
            color: "white"
        }
        background {
            radius: 4
            border.color: "gray"
        }
        indicator {
            width: 20
            height: 20
            border.width: 1
        }
        handle {
            width: 20
            height: 20
            radius: 10
        }
    }

    button {
        background {
            width: 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...
}

Véase también All stylable controls, Style, Theme, StyleVariation, ControlStateStyle y DelegateStyle.

Documentación sobre la propiedad

variations : list<StyleVariation>

Una lista de elementos « type variations » para este tipo de control.

Una variación de tipo proporciona estilos alternativos para los controles que son hijos (o descendientes) de este tipo de control. Por ejemplo, puedes utilizarla para aplicar un estilo diferente a todas las « buttons » dentro de un « frame » en comparación con los botones que se encuentran en otras partes:

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 específicas de un control desde la aplicación mediante la propiedad adjunta « StyleVariation::variations »—, las variaciones de tipo se aplican a todas las instancias de un tipo de control desde el « Style », sin que sea necesario que la aplicación las active.

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.