En esta página

AbstractStylableControls QML Type

Tipo base abstracto que contiene los tipos de control que pueden ser estilizados. Más...

Import Statement: import Qt.labs.StyleKit
Inherited By:

AbstractStyle, Style, StyleVariation, and Theme

Propiedades

Descripción detallada

AbstractControls es un tipo base abstracto. Contiene un ControlStyle para cada tipo de control que puede ser estilizado por un Style, Theme, o StyleVariation.

Los tipos de control forman una jerarquía en la que las propiedades establecidas en un tipo base se propagan a los más específicos. Por ejemplo, asignar un radio de cuatro a abstractButton.background.radius hará que todos los tipos de botón, como button, checkBox, y radioButton, tengan un radio de cuatro.

Los fragmentos de esta página ilustran algunas de las propiedades clave que pueden utilizarse para dar estilo a cada tipo de control, pero no son en absoluto exhaustivos. Hay muchas otras propiedades disponibles, como se documenta en la documentación de ControlStyle y DelegateStyle. En la práctica, algunas de ellas pueden omitirse porque fallback style ya proporciona valores por defecto razonables. Esto significa que si simplemente eliminas una propiedad de uno de los fragmentos, puede que en realidad no afecte a su apariencia, ya que simplemente se leerá del estilo por defecto en su lugar.

Nota: No se garantiza que los tipos de los módulos Qt.labs sigan siendo compatibles en futuras versiones.

Documentación de propiedades

abstractButton : ControlStyle

Propiedad agrupada para estilizar todos los controles tipo botón, incluyendo Button, CheckBox, RadioButton, y Switch. Las propiedades no agrupadas vuelven a control.

abstractButton.background.radius: 4 // all buttons get a radius of 4
checkBox.indicator.radius: 2 // except check boxes, which get a radius of 2

Véase también Tipos de control.

applicationWindow : ControlStyle

Propiedad agrupada para estilizar ApplicationWindow.

Las propiedades no establecidas vuelven a control.

Utilice applicationWindow para establecer el color de fondo de la ventana:

light: Theme {
    applicationWindow.background.color: "#f0f0f0"
}
dark: Theme {
    applicationWindow.background.color: "#404040"
}

Nota: La aplicación necesita usar ApplicationWindow, no Window, para que esto tenga efecto.

button : ControlStyle

Propiedad agrupada para estilizar Button.

Las propiedades no establecidas vuelven a abstractButton.

button {
    background {
        implicitWidth: 120
        implicitHeight: 40
        shadow {
            opacity: 0.6
            color: "gray"
            verticalOffset: 2
            horizontalOffset: 2
        }
        color: "cornflowerblue"
        gradient: Gradient {
            // The gradient is drawn on top of the 'background.color', so
            // we use semi-transparent stops to give the button some shading
            // while letting the base color show through. This makes it easier
            // to change the color, but keep the shading, in the hovered state below.
            GradientStop { position: 0.0; color: Qt.alpha("black", 0.0)}
            GradientStop { position: 1.0; color: Qt.alpha("black", 0.2)}
        }
    }
    text.color: "white"
    hovered.background.color: "royalblue"
    pressed.background.scale: 0.95
}

checkBox : ControlStyle

Propiedad agrupada para estilizar CheckBox.

Las propiedades no establecidas vuelven a abstractButton.

checkBox {
    // Hide the button background; show only the indicator and text
    background.visible: false

    indicator {
        color: "white"
        border.color: "darkslategray"
        foreground {
            color: "transparent"
            image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/check.png"
            image.color: palette.accent

            // Hide the checkmark when the checkbox is not checked
            visible: false
        }
    }

    // Show the checkmark when the checkbox is checked
    checked.indicator.foreground.visible: true
}

comboBox : ControlStyle

Propiedad agrupada para estilizar ComboBox.

Las propiedades no establecidas vuelven a control.

comboBox {
    text.alignment: Qt.AlignHCenter | Qt.AlignVCenter
    background.topLeftRadius: 4
    background.topRightRadius: 4

    indicator {
        // Show only the dropdown arrow, not the indicator background
        color: "transparent"
        border.width: 0
        foreground {
            image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/drop-indicator.png"
            image.color: "black"
        }
    }
}

control : ControlStyle

Propiedad agrupada para dar estilo a todos los controles.

control es el tipo base en la jerarquía de controles, y las propiedades establecidas aquí sirven como valores por defecto para todos los demás tipos de control. Por ejemplo, establecer control.implicitWidth: 200 hace que todos los controles tengan 200 píxeles de ancho, incluyendo botones, indicadores de desplazamiento y cualquier otro control. También anula cualquier valor heredado de un nivel superior en la jerarquía de estilos (el Style para un Theme, o el fallbackStyle para un Style), incluyendo los efectos hover y otros comportamientos basados en el estado. Utilice control con moderación, y prefiera tipos base más específicos como abstractButton o pane cuando sea posible.

control {
    padding: 8
    background.radius: 4
}

flatButton : ControlStyle

Propiedad agrupada para estilizar botones planos (botones sin fondo visible en su estado normal). El estilo tendrá efecto en Button si Button.flat se establece en true.

Las propiedades no establecidas vuelven a abstractButton.

flatButton {
    // Hide background normally, show on hover
    background.visible: false
    hovered.background.visible: true
}

frame : ControlStyle

Propiedad agrupada para estilizar Frame.

Las propiedades no establecidas vuelven a pane.

frame {
    background {
        color: "#fafafa"
        border.color: "#d0d0d0"
        radius: 4
    }
}

groupBox : ControlStyle

Propiedad agrupada para estilizar GroupBox.

Las propiedades no establecidas vuelven a frame.

groupBox {
    // A group box is a container for other controls, so we give it some
    // padding to avoid the child controls to be too close to the border
    padding: 20

    // Move the label to the right, to match the radius of the background
    text.leftPadding: 6
    text.color: "darkslategray"

    background {
        // Move the frame down, below the text label
        topMargin: 30
        radius: 6
        color: "#f8f8f8"
        border.color: "#d0d0d0"
    }
}

itemDelegate : ControlStyle

Propiedad agrupada para estilizar ItemDelegate.

Las propiedades no agrupadas vuelven a control.

Nota: En Qt Quick Controls, ItemDelegate hereda de AbstractButton. En StyleKit, sin embargo, itemDelegate vuelve a control en lugar de abstractButton, ya que los delegados suelen tener un estilo muy diferente al de los botones (plano, sin bordes ni sombras, etc.).

itemDelegate {
    text.alignment: Qt.AlignVCenter | Qt.AlignLeft
    background {
        radius: 0
        color: "white"
        border.width: 0
    }
    hovered.background.color: "#f0f0f0"
}

label : ControlStyle

Propiedad agrupada para estilizar Label.

Las propiedades no establecidas vuelven a control.

light: Theme {
    // Labels typically have no background, so set background.visible to false.
    // Alternatively, hiding the background for labels can be done once for all
    // themes by setting Style.label.background.visible: false.
    label.background.visible: false
    label.text.color: "black"
}
dark: Theme {
    label.background.visible: false
    label.text.color: "white"
}

page : ControlStyle

Propiedad agrupada para estilizar Page.

Las propiedades no establecidas vuelven a pane.

page {
    background {
        color: "white"
        border.width: 0
    }
}

pane : ControlStyle

Propiedad agrupada para estilizar Pane.

Las propiedades no establecidas vuelven a control.

pane {
    background {
        implicitWidth: 200
        implicitHeight: 200
        color: "white"
    }
}

Propiedad agrupada para estilizar Popup.

Las propiedades no establecidas vuelven a control.

popup {
    background {
        color: "white"
        border.width: 1
        border.color: "darkslategray"
        radius: 4
    }
}

progressBar : ControlStyle

Propiedad agrupada para estilizar ProgressBar. Para una barra de progreso, la ranura se estiliza a través del indicador, mientras que la pista de progreso se estiliza a través del primer plano del indicador.

Las propiedades no establecidas vuelven a control.

progressBar {
    // Hide the background; show only the progress bar
    background.visible: false
    indicator {
        implicitWidth: 150
        implicitHeight: 8
        radius: 4
        color: "#e0e0e0"
        foreground {
            // Set margins to add some space between the progress track and the groove
            margins: 2
            color: palette.accent
            radius: 4
        }
    }
}

StyleKit no proporciona una propiedad dedicada para dar estilo a la animación indeterminada de una barra de progreso. Para cambiar la animación, es necesario implementar un primer plano de indicador personalizado delegate en su lugar:

progressBar {
    indicator {
        implicitWidth: 150
        implicitHeight: 8
        foreground {
            delegate: StyledItem {
                // Draw a pulsating progress track when in indeterminate mode, and a normal track otherwise
                width: control.indeterminate ? parent.width : parent.width * control.visualPosition
                height: parent.height
                opacity: control.indeterminate ? 0.1 : 1.0
                SequentialAnimation on opacity {
                    running: control.indeterminate
                    loops: Animation.Infinite
                    NumberAnimation { from: 0.1; to: 1.0; duration: 500; easing.type: Easing.InOutQuad }
                    NumberAnimation { from: 1.0; to: 0.1; duration: 500; easing.type: Easing.InOutQuad }
                }
            }
        }
    }
}

radioButton : ControlStyle

Propiedad agrupada para estilizar RadioButton.

Las propiedades no establecidas vuelven a abstractButton.

radioButton {
    // Hide the button background; show only the indicator and text
    background.visible: false

    indicator {
        // Make the indicator circular
        radius: 255
        foreground {
            // The foreground circle is what shows the checked state, so we make
            // it a bit smaller than the outer circle by setting margins
            margins: 4
            radius: 255
            // Hide the foreground circle when the radio button is not checked
            visible: false
        }
    }

    // Show the foreground circle when the radio button is checked
    checked.indicator.foreground.visible: true
}

scrollBar : ControlStyle

Propiedad agrupada para estilizar ScrollBar. Para una barra de desplazamiento, la ranura se estiliza a través del indicador, mientras que el asa se estiliza a través del primer plano del indicador.

Las propiedades no establecidas vuelven a control.

scrollBar {
    padding: 0
    background {
        // For scroll bars, we typically don't want a background, only a
        // draggable indicator and a groove.
        visible: false
        // Note: even if the background is hidden, its implicit size is still used to
        // determine the overall size of the scroll bar. So we set implicitHeight equal to
        // the height of the indicator, to make it appear on the side of, and not on top
        // of, the content area in a ScrollView. For a horizontal scroll bar, on the other
        // hand, the width is automatically set by the view to match its own width.
        implicitHeight: 10
    }
    indicator {
        radius: 255
        // For horizontal scroll bars, we only set the height. The width is set by the
        // view to be the relative size of the view's content that is currently visible.
        implicitHeight: 10
        color: "#c0c0c0"
        foreground.visible: false
    }
    vertical {
        // Override properties for vertical scroll bars if needed.
        // For vertical indicators, we only set width. The height is set by the
        // view to be the relative size of the view's content that is currently visible.
        indicator.implicitWidth: 10
        background.implicitWidth: 10
    }
}

scrollIndicator : ControlStyle

Propiedad agrupada para estilizar ScrollIndicator.

Las propiedades no establecidas vuelven a control.

scrollIndicator {
     // For scroll indicators, we typically don't want a background, only a
     // sliding indicator
    background.visible: false
    indicator {
        // For horizontal indicators, we only set the height. The width is set by the
        // view to be the relative size of the view's content that is currently visible.
        implicitHeight: 5
        border.width: 0
        color: "cornflowerblue"
        // The indicator is so simple that it doesn't need a foreground
        foreground.visible: false
    }
    vertical {
        // Override properties for vertical scroll indicators if needed
        indicator.color: "violet"
        // For vertical indicators, we only set width. The height is set by the
        // view to be the relative size of the view's content that is currently visible.
        indicator.implicitWidth: 5
    }
}

scrollView : ControlStyle

Propiedad agrupada para estilizar ScrollView.

ScrollView no tiene delegados visuales a los que aplicar estilo. Sus barras de desplazamiento pueden estilizarse por separado a través de la propiedad scrollBar. Pero puede utilizar padding para controlar el espacio entre las barras de desplazamiento y el área de contenido.

Las propiedades no establecidas vuelven a control.

scrollView {
    // Add some space between the scroll bars and the content area
    padding: 2
    // For the sake of the example, style the scroll bars in a ScrollView
    // differently from the default scroll bars by using a StyleVariation.
    variations: StyleVariation {
        scrollBar.indicator.color: "cornflowerblue"
    }
}

slider : ControlStyle

Propiedad agrupada para estilizar Slider. Para una barra deslizante, la ranura se estiliza a través del indicador, mientras que la pista de progreso se estiliza a través del primer plano del indicador. Las propiedades no establecidas vuelven a control.

slider {
    background.visible: false

    indicator {
        // The groove of the slider should fill out the entire width of
        // the control, which we achieve by setting implicitWidth to Style.Stretch.
        implicitWidth: Style.Stretch
        implicitHeight: 8
        radius: 255
        color: "#e0e0e0"
        foreground {
            radius: 255
            color: palette.accent
        }
    }

    handle {
        implicitWidth: 24
        implicitHeight: 24
        radius: 255
        color: "white"
        border.color: "#c0c0c0"
    }

    vertical {
        // if needed, you can override properties for vertical sliders
    }
}

spinBox : ControlStyle

Propiedad agrupada para estilizar SpinBox.

Las propiedades no agrupadas vuelven a control.

spinBox {
    // Center the text between the up/down buttons
    text.alignment: Qt.AlignHCenter | Qt.AlignVCenter

    indicator {
        color: "transparent"
        border.width: 0
        foreground {
            image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/arrow-indicator.png"
            image.color: "black"
            alignment: Qt.AlignCenter
        }
        // Place the down and up buttons on the left and right side of the control
        down {
            alignment: Qt.AlignLeft
            foreground.rotation: 90
        }
        up {
            alignment: Qt.AlignRight
            foreground.rotation: -90
        }
    }
}

Nota: Actualmente sólo es posible colocar los botones arriba y abajo a la izquierda o a la derecha del control, pero no uno encima del otro.

switchControl : ControlStyle

Propiedad agrupada para estilizar Switch.

Las propiedades no establecidas vuelven a abstractButton.

switchControl {
    // For a switch control, we typically don't want a background, only an indicator with a handle
    background.visible: false
    indicator {
        radius: 12
        foreground {
            // Add some space between the indicator and the foreground track
            margins: 2
            radius: 12
            // The foreground track should only be visible when the switch is checked
            visible: false
        }
    }
    checked.indicator.foreground.visible: true
    handle {
        // Add some space between the handle and the indicator
        leftMargin: 2
        rightMargin: 2
        implicitWidth: 20
        implicitHeight: 20
        radius: 255
        color: "white"
    }
}

tabBar : ControlStyle

Propiedad agrupada para estilizar TabBar.

Las propiedades no establecidas vuelven a pane.

tabBar {
    padding: 0
    spacing: -1 // let tab buttons overlap slightly
    background {
        color: "white"
        border.width: 0
    }
}

tabButton : ControlStyle

Propiedad agrupada para estilizar TabButton.

Las propiedades no establecidas vuelven a abstractButton.

tabButton {
    background {
        radius: 0
        topLeftRadius: 4
        topRightRadius: 4
        color: "#e8e8e8"
    }
    checked.background.color: "white"
}

textArea : ControlStyle

Propiedad agrupada para estilizar TextArea.

Las propiedades no establecidas vuelven a textInput.

textArea {
    // Add some space between the text and the border of the text area
    padding: 8
    text.color: "black"
    background {
        color: "white"
        border.color: "#c0c0c0"
    }
    focused.background.border.color: palette.accent
}

textField : ControlStyle

Propiedad agrupada para estilizar TextField.

Las propiedades no establecidas vuelven a textInput.

textField {
    // Add some space between the text and the border of the text field
    padding: 8
    text.alignment: Qt.AlignVCenter
    background {
        implicitWidth: 150
        color: "white"
        border.color: "#c0c0c0"
    }
    focused.background.border.color: palette.accent
}

textInput : ControlStyle

Propiedad agrupada para estilizar todos los controles de entrada de texto, incluidos TextField y TextArea.

Las propiedades no agrupadas vuelven a control.

textInput {
    // Add some space between the text and the border of the text input
    padding: 8
    text.color: "black"
    background {
        color: "white"
        border.width: 1
        border.color: "#c0c0c0"
    }
}

toolBar : ControlStyle

Propiedad agrupada para estilizar ToolBar.

Las propiedades no establecidas vuelven a pane.

toolBar {
    spacing: 2
    background {
        radius: 0
        implicitHeight: 40
        border.width: 1
    }
}

toolButton : ControlStyle

Propiedad agrupada para estilizar ToolButton.

Las propiedades no establecidas vuelven a abstractButton.

toolButton {
    background.radius: 0
}

toolSeparator : ControlStyle

Propiedad agrupada para estilizar ToolSeparator.

Las propiedades no establecidas vuelven a control.

toolSeparator {
    background.visible: false
    indicator {
        implicitWidth: 30
        implicitHeight: 1
        border.width: 0
        color: "#c0c0c0"
        foreground.visible: false
    }
    vertical {
        // Override properties for vertical tool separators if needed.
        // Note: Qt Quick Controls automatically swaps the width and height
        // for vertical tool separators, so avoid doing that here.
    }
}

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