Nesta página

ControlStyle QML Type

Define o estilo de um controle no estado “ normal ”. Mais...

Import Statement: import Qt.labs.StyleKit
Inherits:

ControlStateStyle

Inherited By:

CustomControl

Status: Technology preview

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

Propriedades

Descrição detalhada

Um ControlStyle descreve como um Control deve ser estilizado. Sua API reflete amplamente a de um controle Qt Quick: ela fornece propriedades agrupadas para delegados, como background, indicator, handle e text, juntamente com propriedades de layout, como padding e spacing. Se você estiver familiarizado com a API de um Control nos controles Qt Quick, deverá achar a API do ControlStyle fácil de entender.

O `ControlStyle` herda de ` ControlStateStyle ` porque representa o estado normal: as propriedades definidas diretamente em um `ControlStyle` descrevem a aparência do controle quando nenhum outro estado está ativo. As substituições específicas de estado são definidas por meio de estados aninhados, como ` hovered `, ` pressed` e ` checked`.

Each stylable control em um Style, Theme ou StyleVariation é um ControlStyle. Por exemplo, no trecho abaixo, control, button e radioButton são todos ControlStyles:

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

Veja também All stylable controls, Style, Theme, StyleVariation, ControlStateStyle e DelegateStyle.

Documentação de propriedades

variations : list<StyleVariation>

Uma lista de type variations para esse tipo de controle.

Uma variação de tipo oferece estilos alternativos para controles que são filhos (ou descendentes) desse tipo de controle. Por exemplo, você pode usá-la para aplicar estilos diferentes a todas as instâncias de ` buttons ` dentro de um ` frame ` em comparação com botões em outros locais:

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: []
    }
}

Ao contrário das variações de instância — que são aplicadas a instâncias específicas de controle a partir do aplicativo por meio da propriedade anexada ` StyleVariation::variations ` —, as variações de tipo são aplicadas a todas as instâncias de um tipo de controle a partir do ` Style`, sem que seja necessário que o aplicativo as ative.

Consulte também 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.