Nesta página

StylableControls QML Type

Tipo base abstrato que contém os tipos de controle aos quais é possível aplicar estilos. Mais...

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

AbstractStyle, Style, StyleVariation, and Theme

Status: Technology preview

Este tipo está em pré-visualização tecnológica e está sujeito a alterações.

Propriedades

Métodos

Descrição detalhada

StylableControls é um tipo base abstrato. Ele contém um ` ControlStyle ` para cada tipo de controle que pode ser estilizado por um ` Style`, ` Theme` ou ` StyleVariation`.

Os tipos de controle formam uma hierarquia na qual as propriedades definidas em um tipo base se propagam para os tipos mais específicos. Por exemplo, atribuir um raio de quatro a ` abstractButton.background.radius ` fará com que todos os tipos de botão, como ` button`, ` checkBox` e ` radioButton`, recebam um raio de quatro.

Os trechos de código nesta página ilustram algumas das principais propriedades que podem ser usadas para definir o estilo de cada tipo de controle, mas não são, de forma alguma, exaustivos. Muitas outras propriedades estão disponíveis, conforme documentado na documentação de ControlStyle e DelegateStyle. Na prática, algumas delas também podem ser omitidas, pois o fallback style já fornece padrões sensatos. Isso significa que, se você simplesmente remover uma propriedade de um dos trechos de código, isso pode não afetar sua aparência, já que ela será lida a partir do estilo alternativo.

Observação: não há garantia de que os tipos nos módulos do Qt.labs permanecerão compatíveis em versões futuras.

Veja também Resolução de Propriedades doStyleKit.

Documentação de propriedades

abstractButton : ControlStyle

Propriedade agrupada para definir o estilo de todos os controles semelhantes a botões, incluindo Button, CheckBox, RadioButton, Switch e RoundButton. As propriedades não definidas assumem o valor padrão 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

Veja também Tipos de controle.

applicationWindow : ControlStyle

Propriedade agrupada para estilização ApplicationWindow.

As propriedades não definidas assumem o valor padrão de ` control`.

Use ` applicationWindow ` para definir a cor de fundo da janela:

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

Observação: o aplicativo precisa usar ` ApplicationWindow`, e não `Window`, para que isso tenha efeito.

busyIndicator : ControlStyle

Propriedade agrupada para estilização BusyIndicator.

Propriedades não definidas assumem o valor padrão de control.

busyIndicator {
    background {
        visible: false
        width: 48
        height: 48
    }
    indicator {
        fillWidth: true
        fillHeight: true
        color: "transparent"
        border.width: 0
        foreground {
            radius: 255
            color: palette.accent
        }
    }
}

O StyleKit não oferece propriedades específicas para definir o estilo da animação do indicador giratório. Para alterar a forma ou a animação do indicador giratório, é necessário implementar um indicador personalizado no primeiro plano delegate:

busyIndicator {
    background {
        visible: false
        width: 48
        height: 48
    }
    indicator {
        fillWidth: true
        fillHeight: true
        color: "transparent"
        border.width: 0
        foreground {
            radius: 255
            color: palette.accent
            delegate: Text {
                required property DelegateStyle delegateStyle
                required property QtObject control
                opacity: control.running ? 1 : 0
                Behavior on opacity { NumberAnimation{} }
                text: "↻"
                color: delegateStyle.color
                font.pixelSize: 20
                RotationAnimation on rotation {
                    from: 0
                    to: 360
                    duration: 1000
                    loops: Animation.Infinite
                    running: control.running
                }
            }
        }
    }
}

button : ControlStyle

Propriedade agrupada para estilo Button.

As propriedades não definidas assumem o valor padrão de abstractButton.

button {
    background {
        width: 120
        height: 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

Propriedade agrupada para estilização CheckBox.

As propriedades não definidas assumem o valor padrão de 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
}

checkDelegate : ControlStyle

Propriedade agrupada para estilização CheckDelegate.

As propriedades não definidas assumem o valor padrão de itemDelegate.

checkDelegate {
    text.alignment: Qt.AlignHCenter | Qt.AlignVCenter
    background {
        radius: 0
        color: "white"
        border.width: 0
    }

    indicator {
        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
        }
    }

    hovered.background.color: "#f0f0f0"
    // Show the checkmark when the checkbox is checked
    checked.indicator.foreground.visible: true
}

comboBox : ControlStyle

Propriedade agrupada para estilização ComboBox.

As propriedades não definidas assumem o valor padrão de control.

Observação: defina o estilo do pop-up por meio de ` popup` e o de seus itens por meio de ` itemDelegate`.

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

Propriedade agrupada para definir o estilo de todos os controles.

control É o tipo base na hierarquia de controles, e as propriedades definidas aqui servem como padrões para todos os outros tipos de controle. Por exemplo, definir ` control.width: 200 ` faz com que todos os controles tenham 200 pixels de largura, incluindo botões, indicadores de rolagem e todos os outros controles. Isso também substitui quaisquer valores herdados de um nível superior na hierarquia de estilos (o ` Style ` para um ` Theme` ou o ` fallbackStyle ` para um ` Style`), incluindo efeitos de hover e outros comportamentos baseados em estado. Use ` control ` com moderação e prefira tipos base mais específicos, como ` abstractButton ` ou ` pane `, sempre que possível.

control {
    padding: 8
    background.radius: 4
}

delayButton : ControlStyle

Propriedade agrupada para definir o estilo de DelayButton.

Para um botão de atraso, o progresso é estilizado por meio do indicador. Por padrão, o próprio indicador é transparente e não possui borda, de modo que apenas o primeiro plano do indicador fica visível à medida que ele é preenchido.

As propriedades não definidas voltam ao valor padrão de abstractButton.

delayButton {
    padding: 0
    indicator {
        fillWidth: true
        fillHeight: true
        color: "transparent"
        border.width: 0
        foreground.color: palette.accent
    }
    checked.indicator.foreground.color: palette.accent.darker(1.2)
}

dial : ControlStyle

Propriedade agrupada para estilização Dial.

As propriedades não definidas assumem o valor padrão de control.

dial {
    spacing: 0
    handle.width: 15
    handle.height: 15
    background.visible: false
    indicator {
        width: 60
        height: 60
        radius: 255
        foreground {
            fillWidth: true
            fillHeight: true
            width: 6
            height: 6
            color: palette.accent
        }
    }
}

dialog : ControlStyle

Propriedade agrupada para estilo Dialog.

As propriedades não definidas assumem o valor padrão de popup.

dialog {
    text {
        padding: 12
        alignment: Qt.AlignHCenter | Qt.AlignVCenter
    }

    background.color: "white"
}

dialogButtonBox : ControlStyle

Propriedade agrupada para estilização DialogButtonBox.

As propriedades não definidas assumem o valor padrão de pane.

dialogButtonBox {
    background {
        height: 40
        radius: 0
        color: "transparent"
        border.width: 0
    }
}

flatButton : ControlStyle

Propriedade agrupada para definir o estilo de botões planos (botões sem fundo visível em seu estado normal). O estilo será aplicado a um ` Button ` se ` Button.flat ` estiver definido como ` true`.

As propriedades não definidas assumem o valor padrão ` abstractButton`.

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

frame : ControlStyle

Propriedade agrupada para estilização: Frame.

As propriedades não definidas recorrem ao valor padrão pane.

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

groupBox : ControlStyle

Propriedade agrupada para estilização GroupBox.

As propriedades não definidas assumem o valor padrão de 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

Propriedade agrupada para estilo: ItemDelegate.

As propriedades não definidas assumem o valor padrão de control.

Observação: Nos controles do Qt Quick, ` ItemDelegate ` herda de ` AbstractButton`. No StyleKit, no entanto, ` itemDelegate ` recorre a ` control ` em vez de ` abstractButton`, já que os delegados geralmente têm um estilo muito diferente dos botões (design plano, sem bordas ou sombras, etc.).

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

label : ControlStyle

Propriedade agrupada para estilização Label.

As propriedades não definidas assumem o valor padrão de 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"
}

Propriedade agrupada para estilização Menu.

As propriedades não definidas recorrem a popup.

menu {
    background {
        width: 200
        height: 40
        border.color: "darkslategray"
        radius: 4
    }
}

Propriedade agrupada para estilização MenuBar.

As propriedades não definidas assumem o valor padrão de control.

Observação: A aplicação de estilos em MenuBar, MenuBarItem e MenuSeparator normalmente afeta apenas barras de menu não nativas. Quando um MenuBar é implementado como uma barra de menu nativa, seus delegados não são usados para renderização; portanto, as propriedades de estilo do StyleKit podem não ter efeito visual. Consulte Barras de menu nativas para obter mais detalhes.

menuBar {
    background {
        radius: 0
        border.width: 0
    }
}

Propriedade agrupada para aplicar estilos aos itens de menu em um MenuBar.

As propriedades não definidas assumem o valor padrão de control.

Observação: Nos controles do Qt Quick, um MenuBarItem herda de AbstractButton. No StyleKit, no entanto, menuBarItem é um tipo de controle separado que recorre a control em vez de abstractButton, já que os itens da barra de menu geralmente têm um estilo muito diferente dos botões comuns (plano, sem bordas ou sombras projetadas, etc.).

menuBarItem {
    text.alignment: Qt.AlignLeft | Qt.AlignVCenter
    background {
        radius: 0
        color: "transparent"
        border.width: 0
    }
    hovered.background.color: "#c0c0c0"
}

Propriedade agrupada para estilização MenuItem.

As propriedades não definidas assumem o valor padrão de control.

Observação: Nos controles do Qt Quick, um MenuItem herda de AbstractButton. No StyleKit, no entanto, menuItem recorre a control em vez de abstractButton, já que os itens de menu geralmente têm um estilo muito diferente dos botões comuns (design plano, sem bordas ou sombras projetadas, etc.).

menuItem {
    text.alignment: Qt.AlignVCenter | Qt.AlignLeft
    background {
        width: 200
        border.width: 0
    }
    indicator {
        color: "transparent"
        border.width: 0
        foreground {
            image.color: palette.accent
            alignment: Qt.AlignCenter
        }
        first {
            alignment: Qt.AlignLeft
            foreground.image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/check.png"
        }
        second {
            alignment: Qt.AlignRight
            foreground.image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/arrow-indicator.png"
        }
    }
    hovered.background.color: "#c0c0c0"
}

Propriedade agrupada para estilização MenuSeparator.

As propriedades não definidas assumem o valor padrão de control.

menuSeparator {
    background.visible: false
    indicator {
        width: 188
        height: 1
        border.width: 0
        color: "#c0c0c0"
        foreground.visible: false
    }
}

page : ControlStyle

Propriedade agrupada para estilização Page.

Propriedades não definidas assumem o valor padrão de pane.

Observe que os valores de ` header ` e ` footer ` de um ` Page ` são normalmente definidos pelo aplicativo como ` ToolBar ` ou ` TabBar`, e esses controles recebem estilo separadamente. Para atribuir um estilo alternativo a um ` ToolBar ` quando usado dentro de um ` Page`, utilize um ` StyleVariation`:

page {
    background {
        color: "white"
        border.width: 0
    }
    variations: StyleVariation {
        toolBar.background.color: "cornflowerblue"
        toolButton.background.color: "skyblue"
        toolButton.background.border.color: "aliceblue"
    }
}

pageIndicator : ControlStyle

Propriedade agrupada para estilização PageIndicator.

As propriedades não definidas assumem o valor padrão de control.

pageIndicator {
    background.visible: false
    indicator {
        width: 5
        height: 5
        radius: 255
        border.width: 0
        color: "black"
        opacity: 0.45
        foreground.visible: false
    }

    hovered.indicator {
        width: 6
        height: 6
        opacity: 0.7
    }

    pressed.indicator {
        width: 4
        height: 4
    }

    checked.indicator {
        width: 7
        height: 7
    }

    checked.hovered.indicator {
        width: 8
        height: 8
        opacity: 0.7
    }
}

pane : ControlStyle

Propriedade agrupada para estilização Pane.

As propriedades não definidas assumem o valor padrão de control.

pane {
    background {
        width: 200
        height: 200
        color: "white"
    }
}

Propriedade agrupada para estilização Popup.

As propriedades não definidas assumem o valor padrão de control.

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

progressBar : ControlStyle

Propriedade agrupada para estilização ProgressBar. No caso de uma barra de progresso, o sulco é estilizado por meio do indicador, enquanto a trilha de progresso é estilizada por meio do primeiro plano do indicador.

Propriedades não definidas recorrem a control.

progressBar {
    // Hide the background; show only the progress bar
    background.visible: false
    indicator {
        width: 150
        height: 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
        }
    }
}

O StyleKit não oferece uma propriedade dedicada para estilizar a animação indeterminada de uma barra de progresso. Para alterar a animação, é necessário implementar um primeiro plano personalizado para o indicador delegate:

progressBar {
    indicator {
        width: 150
        height: 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

Propriedade agrupada para estilo: RadioButton.

As propriedades não definidas assumem o valor padrão de 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
}

radioDelegate : ControlStyle

Propriedade agrupada para estilização RadioDelegate.

As propriedades não definidas assumem o valor padrão de itemDelegate.

radioDelegate {
    text.alignment: Qt.AlignVCenter | Qt.AlignLeft
    background {
        radius: 0
        color: "white"
        border.width: 0
    }

    indicator {
        radius: 255
        foreground {
            margins: 4
            visible: false
            radius: 255
            color: palette.accent
        }
    }

    hovered.background.color: "#f0f0f0"
    checked.indicator.foreground.visible: true
}

roundButton : ControlStyle

Propriedade agrupada para estilização RoundButton.

As propriedades não definidas assumem o valor padrão de abstractButton.

roundButton {
    background.radius: 255
    text.alignment: Qt.AlignVCenter | Qt.AlignHCenter
}

scrollBar : ControlStyle

Propriedade agrupada para definição de estilo: ScrollBar. O sulco é estilizado por meio de background, e a alça por meio de indicator.

As propriedades não definidas assumem o valor padrão control.

scrollBar {
    padding: 0
    background {
        // Set the groove size and color
        width: 10
        height: 10
        color: "white"
    }
    indicator {
        radius: 255
        fillWidth: true
        width: 10
        height: 10
        color: "#c0c0c0"
        // The indicator is so simple that it doesn't need a foreground
        foreground.visible: false
    }
    vertical {
        indicator {
            // In vertical mode, the indicator should stretch vertically
            // to fill the available height rather than the available width.
            fillWidth: false
            fillHeight: true
        }
    }
}

scrollIndicator : ControlStyle

Propriedade agrupada para definição de estilo: ScrollIndicator. O sulco é estilizado por meio de background, e a alça por meio de indicator.

As propriedades não definidas assumem o valor padrão de control.

scrollIndicator {
    // A scroll indicator typically has no groove, just a sliding
    // indicator. So hide the background, since it represents the groove.
    background.visible: false
    indicator {
        fillWidth: true
        width: 5
        height: 5
        border.width: 0
        color: "cornflowerblue"
        // The indicator is so simple that it doesn't need a foreground
        foreground.visible: false
    }
    vertical {
        indicator {
            // In vertical mode, the indicator should stretch vertically
            // to fill the available height rather than the available width.
            fillWidth: false
            fillHeight: true
        }
    }
}

scrollView : ControlStyle

Propriedade agrupada para aplicar estilo a ScrollView.

ScrollView A propriedade em si não possui elementos visuais para aplicar estilo. Suas barras de rolagem podem ser estilizadas separadamente por meio da propriedade ` scrollBar `. No entanto, é possível usar ` padding ` para controlar o espaço entre as barras de rolagem e a área de conteúdo.

Propriedades não definidas assumem o valor padrão de ` 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"
    }
}

searchField : ControlStyle

Propriedade agrupada para estilização SearchField.

As propriedades não definidas usam como padrão control.

searchField {
    // Center the text between the buttons
    text.padding: 5
    text.alignment: Qt.AlignVCenter | Qt.AlignLeft
    text.color: "black"
    background.width: 200

    indicator {
        color: "transparent"
        border.width: 0

        foreground{
            alignment: Qt.AlignCenter
        }

        // Place the search and clear buttons on the left and right side of the control
        // search button
        first {
            alignment: Qt.AlignLeft
            image.color: "black"
            image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/search-magnifier.png"
        }

        // clear button
        second {
            alignment: Qt.AlignRight
            image.color: "black"
            image.source: "qrc:/qt-project.org/imports/QtQuick/Controls/Basic/images/close_circle.png"
        }
    }
}

slider : ControlStyle

Propriedade agrupada para definição de estilo Slider. No caso de um controle deslizante, o sulco é estilizado por meio do indicador, enquanto a barra de progresso é estilizada por meio do primeiro plano do indicador.

As propriedades não definidas assumem o valor padrão de ` control`.

Para controles deslizantes verticais, troque as propriedades ` width ` e ` height ` dos delegados relevantes, de modo que o controle fique mais alto do que largo, conforme mostrado no trecho de código abaixo.

slider {
    background {
        // The background is hidden, but its implicit size still
        // determines the overall implicit size of the control.
        visible: false
        width: 150
        height: 50
    }

    indicator {
        // The groove of the slider should fill out the entire width of the control
        fillWidth: true
        height: 8
        radius: 255
        color: "#e0e0e0"
        foreground {
            radius: 255
            color: palette.accent
        }
    }

    handle {
        width: 24
        height: 24
        radius: 255
        color: "white"
        border.color: "#c0c0c0"
    }

    vertical {
        // Transpose relevant geometry
        background {
            width: 50
            height: 150
        }

        indicator {
            fillWidth: false
            fillHeight: true
            width: 8
        }
    }
}

spinBox : ControlStyle

Propriedade agrupada para estilo SpinBox.

As propriedades não definidas assumem o valor padrão de 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
        // up button
        first {
            alignment: Qt.AlignRight
            foreground.rotation: -90
        }
        // down button
        second {
            alignment: Qt.AlignLeft
            foreground.rotation: 90
        }
    }
}

Observação: no momento, sóé possível posicionar os botões para cima e para baixo à esquerda ou à direita do controle, mas não um sobre o outro.

swipeDelegate : ControlStyle

Propriedade agrupada para estilização SwipeDelegate.

As propriedades não definidas recorrem a itemDelegate.

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

switchControl : ControlStyle

Propriedade agrupada para estilização Switch.

As propriedades não definidas voltam ao padrão 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
        width: 20
        height: 20
        radius: 255
        color: "white"
    }
}

switchDelegate : ControlStyle

Propriedade agrupada para estilização SwitchDelegate.

As propriedades não definidas assumem o valor padrão de itemDelegate.

switchDelegate {
    text.alignment: Qt.AlignVCenter | Qt.AlignLeft
    background {
        radius: 0
        color: "white"
        border.width: 0
    }

    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
        }
    }

    handle {
        // Add some space between the handle and the indicator
        leftMargin: 2
        rightMargin: 2
        width: 20
        height: 20
        radius: 255
        color: "white"
    }

    hovered.background.color: "#f0f0f0"
    checked.indicator.foreground.visible: true
}

tabBar : ControlStyle

Propriedade agrupada para estilização TabBar.

As propriedades não definidas assumem o valor padrão de pane.

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

tabButton : ControlStyle

Propriedade agrupada para estilo: TabButton.

As propriedades não definidas assumem o valor padrão de abstractButton.

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

textArea : ControlStyle

Propriedade agrupada para estilização TextArea.

As propriedades não definidas assumem o valor padrão de 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

Propriedade agrupada para estilização TextField.

As propriedades não definidas assumem o valor padrão de textInput.

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

textInput : ControlStyle

Propriedade agrupada para definir o estilo de todos os controles de entrada de texto, incluindo TextField e TextArea.

As propriedades não definidas assumem o valor padrão de ` 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

Propriedade agrupada para estilização ToolBar.

As propriedades não definidas assumem o valor padrão de pane.

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

toolButton : ControlStyle

Propriedade agrupada para estilização ToolButton.

As propriedades não definidas assumem o valor padrão de abstractButton.

toolButton {
    background.radius: 0
}

toolSeparator : ControlStyle

Propriedade agrupada para estilização ToolSeparator.

As propriedades não definidas assumem o valor padrão de ` control`.

Para separadores verticais, troque os valores de ` width ` e ` height ` dos delegados relevantes, de modo que o controle fique mais alto do que largo, conforme mostrado no trecho de código abaixo.

toolSeparator {
    background {
        // The background is hidden, but its implicit size still
        // determines the overall implicit size of the control.
        visible: false
        width: 10
        height: 10
    }
    indicator {
        width: 30
        height: 1
        border.width: 0
        color: "#c0c0c0"
        alignment: Qt.AlignCenter
        foreground.visible: false
    }
    vertical {
        indicator {
            width: 1
            height: 30
        }
    }
}

Documentação do método

ControlStyle getControlStyle(controlType)

Retorna o ControlStyle para o controlType fornecido, ou null, caso nenhum ControlStyle tenha sido definido para o tipo.

controlType pode ser um dos tipos embutidos documentados em StyleReader.controlType, ou o controlType de um CustomControl.

Essa função pode ser usada, por exemplo, para ler ou gravar uma propriedade no estilo de um CustomControl em tempo de execução:

Style {
    id: myStyle
    property int customButtonType: 0

    CustomControl {
        controlType: myStyle.customButtonType
        background.color: "green"
    }
}
function changeButtonColor() {
    let customControlStyle = myStyle.getControlStyle(style.customButtonType)
    customControlStyle.background.color = "yellowgreen"

    // You can also access the style definition in the theme, if it has one
    // myStyle.theme.getControlStyle(StyleReader.Button).padding = 10
}

Se controlType for um tipo embutido (como StyleReader.Button), usar, por exemplo, myStyle.button ou myStyle.getControlStyle(StyleReader.Button) para obter o ControlStyle é quase equivalente. A diferença é que o primeiro criará de forma preguiçosa um ControlStyle se ele ainda não estiver definido, enquanto o segundo retornará null. Isso significa que, por exemplo, myStyle.button.padding = 10 é sempre seguro, enquanto myStyle.getControlStyle(StyleReader.Button).padding = 10 falhará se myStyle.button não tiver sido definido no Style.

Veja também CustomControl e StyleReader.

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