ControlStyle QML Type
Definisce lo stile di un controllo nello stato " normal ". Maggiori informazioni...
| Import Statement: | import Qt.labs.StyleKit |
| Inherits: | |
| Inherited By: | |
| Status: | Technology preview |
Questo tipo è in anteprima tecnologica ed è soggetto a modifiche.
Proprietà
- variations : list<StyleVariation>
Descrizione dettagliata
Un ControlStyle descrive come deve essere stilizzato un Control. La sua API rispecchia in gran parte quella di un controllo Qt Quick: fornisce proprietà raggruppate per i delegati quali background, indicator, handle e text, insieme a proprietà di layout quali padding e spacing. Se avete familiarità con l'API di un Control nei controlli Qt Quick, dovreste trovare l'API di ControlStyle facile da seguire.
ControlStyle eredita da ControlStateStyle poiché rappresenta lo stato normale: le proprietà impostate direttamente su un ControlStyle descrivono l’aspetto del controllo quando nessun altro stato è attivo. Le sovrascritture specifiche per lo stato vengono impostate tramite stati annidati, quali hovered, pressed e checked.
Each stylable control in un Style, Theme o StyleVariation è un ControlStyle. Ad esempio, nel frammento di codice riportato di seguito, control, button e radioButton sono tutti ControlStyle:
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...
}Vedi anche All stylable controls, Style, Theme, StyleVariation, ControlStateStyle e DelegateStyle.
Documentazione sulla proprietà
variations : list<StyleVariation>
Un elenco di type variations per questo tipo di controllo.
Una variazione di tipo fornisce uno stile alternativo per i controlli che sono figli (o discendenti) di questo tipo di controllo. Ad esempio, è possibile utilizzarla per applicare uno stile diverso a tutte le istanze di buttons all'interno di un frame rispetto ai pulsanti presenti altrove:
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 differenza delle variazioni di istanza — che vengono applicate a specifiche istanze di controllo dall'applicazione tramite la proprietà associata StyleVariation::variations — le variazioni di tipo vengono applicate a tutte le istanze di un tipo di controllo dall'Style, senza che l'applicazione debba attivarne l'uso.
Vedi anche 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.