StylableControls QML Type
Tipo base astratto che contiene i tipi di controllo a cui è possibile applicare uno stile. Altro...
| Import Statement: | import Qt.labs.StyleKit |
| Inherited By: | AbstractStyle, Style, StyleVariation, and Theme |
| Status: | Technology preview |
Questo tipo è in anteprima tecnologica ed è soggetto a modifiche.
Proprietà
- abstractButton : ControlStyle
- applicationWindow : ControlStyle
- busyIndicator : ControlStyle
- button : ControlStyle
- checkBox : ControlStyle
- checkDelegate : ControlStyle
- comboBox : ControlStyle
- control : ControlStyle
- delayButton : ControlStyle
- dial : ControlStyle
- dialog : ControlStyle
- dialogButtonBox : ControlStyle
- flatButton : ControlStyle
- frame : ControlStyle
- groupBox : ControlStyle
- itemDelegate : ControlStyle
- label : ControlStyle
- menu : ControlStyle
- menuBar : ControlStyle
- menuBarItem : ControlStyle
- menuItem : ControlStyle
- menuSeparator : ControlStyle
- page : ControlStyle
- pageIndicator : ControlStyle
- pane : ControlStyle
- popup : ControlStyle
- progressBar : ControlStyle
- radioButton : ControlStyle
- radioDelegate : ControlStyle
- roundButton : ControlStyle
- scrollBar : ControlStyle
- scrollIndicator : ControlStyle
- scrollView : ControlStyle
- searchField : ControlStyle
- slider : ControlStyle
- spinBox : ControlStyle
- swipeDelegate : ControlStyle
- switchControl : ControlStyle
- switchDelegate : ControlStyle
- tabBar : ControlStyle
- tabButton : ControlStyle
- textArea : ControlStyle
- textField : ControlStyle
- textInput : ControlStyle
- toolBar : ControlStyle
- toolButton : ControlStyle
- toolSeparator : ControlStyle
Metodi
- ControlStyle getControlStyle(controlType)
Descrizione dettagliata
StylableControls è un tipo base astratto. Contiene un ControlStyle per ciascun tipo di controllo che può essere personalizzato tramite un Style, Theme o StyleVariation.
I tipi di controllo formano una gerarchia in cui le proprietà impostate su un tipo base si propagano verso quelli più specifici. Ad esempio, assegnando un raggio pari a quattro a ` abstractButton.background.radius `, tutti i tipi di pulsante, quali ` button`, ` checkBox` e ` radioButton`, assumeranno un raggio pari a quattro.
Gli snippet presenti in questa pagina illustrano alcune delle proprietà chiave che possono essere utilizzate per definire lo stile di ciascun tipo di controllo, ma non sono affatto esaustivi. Sono disponibili molte altre proprietà, come documentato nella documentazione relativa a ControlStyle e DelegateStyle. In pratica, alcune di esse possono anche essere omesse poiché l’ fallback style e fornisce già valori predefiniti ragionevoli. Ciò significa che se si rimuove semplicemente una proprietà da uno degli snippet, ciò potrebbe non influire effettivamente sul suo aspetto, poiché verrà invece utilizzato lo stile di ripiego.
Nota: non è garantita la compatibilità dei tipi nei moduli Qt.labs nelle versioni future.
Vedi anche Risoluzione delle proprietà di StyleKit.
Documentazione delle proprietà
abstractButton : ControlStyle
Proprietà raggruppata per lo styling di tutti i controlli simili a pulsanti, inclusi Button, CheckBox, RadioButton, Switch e RoundButton. Se le proprietà non sono impostate, viene utilizzato come valore predefinito control.
abstractButton.background.radius: 4 // all buttons get a radius of 4
checkBox.indicator.radius: 2 // except check boxes, which get a radius of 2Vedi anche Tipi di controllo.
applicationWindow : ControlStyle
Proprietà raggruppate per lo styling ApplicationWindow.
Le proprietà non impostate assumono il valore predefinito control.
Utilizzare applicationWindow per impostare il colore di sfondo della finestra:
light: Theme {
applicationWindow.background.color: "#f0f0f0"
}
dark: Theme {
applicationWindow.background.color: "#404040"
}Nota: affinché questa impostazione abbia effetto,l'applicazione deve utilizzare ` ApplicationWindow`, non `Window`.
busyIndicator : ControlStyle
Proprietà raggruppate per lo styling BusyIndicator.
Le proprietà non impostate assumono il valore predefinito 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
}
}
}StyleKit non fornisce proprietà dedicate per personalizzare l'animazione dell'indicatore di caricamento. Per modificare la forma o l'animazione dell'indicatore di caricamento, è necessario implementare un indicatore personalizzato in primo piano 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
Proprietà raggruppate per lo styling Button.
Le proprietà non impostate assumono il valore predefinito di 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
Proprietà raggruppate per lo styling CheckBox.
Le proprietà non impostate assumono il valore predefinito 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
Proprietà raggruppate per lo styling CheckDelegate.
Le proprietà non impostate assumono il valore predefinito 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
Proprietà raggruppate per lo styling ComboBox.
Le proprietà non impostate ricorrono a control.
Nota: applicare lo stile al popup tramite popup e ai suoi elementi tramite 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
Proprietà raggruppata per la personalizzazione di tutti i controlli.
control È il tipo di base nella gerarchia dei controlli e le proprietà impostate qui fungono da valori predefiniti per tutti gli altri tipi di controllo. Ad esempio, impostando control.width: 200, tutti i controlli avranno una larghezza di 200 pixel, inclusi pulsanti, indicatori di scorrimento e ogni altro controllo. Inoltre, sovrascrive qualsiasi valore ereditato da un livello superiore nella gerarchia degli stili (ad esempio, ` Style ` per un ` Theme` o ` fallbackStyle ` per un ` Style`), inclusi gli effetti al passaggio del mouse e altri comportamenti basati sullo stato. Utilizza ` control ` con moderazione e, quando possibile, preferisci tipi di base più specifici come ` abstractButton ` o ` pane `.
control {
padding: 8
background.radius: 4
}delayButton : ControlStyle
Proprietà raggruppate per lo styling di DelayButton.
Nel caso di un pulsante di ritardo, lo stato di avanzamento viene visualizzato tramite l'indicatore. Per impostazione predefinita, l'indicatore stesso è trasparente e privo di bordo, quindi solo la parte in primo piano dell'indicatore è visibile man mano che si riempie.
Le proprietà non specificate assumono il valore predefinito 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
Proprietà raggruppate per lo styling Dial.
Le proprietà non impostate assumono il valore predefinito di 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
Proprietà raggruppate per lo styling Dialog.
Le proprietà non specificate assumono il valore predefinito di popup.
dialog {
text {
padding: 12
alignment: Qt.AlignHCenter | Qt.AlignVCenter
}
background.color: "white"
}dialogButtonBox : ControlStyle
Proprietà raggruppate per lo styling DialogButtonBox.
Le proprietà non impostate ricorrono a pane.
dialogButtonBox {
background {
height: 40
radius: 0
color: "transparent"
border.width: 0
}
}flatButton : ControlStyle
Proprietà raggruppate per lo styling dei pulsanti piatti (pulsanti senza sfondo visibile nel loro stato normale). Lo styling avrà effetto per un Button se Button.flat è impostato su true.
Le proprietà non impostate assumono il valore predefinito abstractButton.
flatButton {
// Hide background normally, show on hover
background.visible: false
hovered.background.visible: true
}frame : ControlStyle
Proprietà raggruppate per lo styling Frame.
Le proprietà non impostate assumono il valore predefinito di pane.
frame {
background {
color: "#fafafa"
border.color: "#d0d0d0"
radius: 4
}
}groupBox : ControlStyle
Proprietà raggruppate per lo styling GroupBox.
Le proprietà non impostate assumono il valore predefinito di 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
Proprietà raggruppate per lo styling ItemDelegate.
Le proprietà non impostate ricorrono a control.
Nota: nei controlli Qt Quick, ItemDelegate eredita da AbstractButton. In StyleKit, tuttavia, itemDelegate ricade su control anziché su abstractButton, poiché lo stile dei delegati è in genere molto diverso da quello dei pulsanti (piatto, senza bordi o ombreggiature, ecc.).
itemDelegate {
text.alignment: Qt.AlignVCenter | Qt.AlignLeft
background {
radius: 0
color: "white"
border.width: 0
}
hovered.background.color: "#f0f0f0"
}label : ControlStyle
Proprietà raggruppate per lo styling Label.
Le proprietà non impostate assumono il valore predefinito di 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"
}menu : ControlStyle
Proprietà raggruppate per lo styling Menu.
Le proprietà non impostate assumono il valore predefinito di popup.
menu {
background {
width: 200
height: 40
border.color: "darkslategray"
radius: 4
}
}menuBar : ControlStyle
Proprietà raggruppate per lo styling MenuBar.
Le proprietà non specificate assumono il valore predefinito di control.
Nota: lo stile applicato a MenuBar, MenuBarItem e MenuSeparator di norma influisce solo sulle barre dei menu non native. Quando un MenuBar è implementato come barra dei menu nativa, i suoi delegati non vengono utilizzati per il rendering, pertanto le proprietà di stile di StyleKit potrebbero non avere alcun effetto visivo. Per ulteriori dettagli, consultare la sezione Barre dei menu native.
menuBar {
background {
radius: 0
border.width: 0
}
}menuBarItem : ControlStyle
Proprietà raggruppate per la personalizzazione delle voci di menu in un MenuBar.
Le proprietà non impostate assumono il valore predefinito di control.
Nota: nei controlli Qt Quick, un MenuBarItem eredita da AbstractButton. In StyleKit, tuttavia, menuBarItem è un tipo di controllo separato che, in caso di mancata impostazione, ricade su control anziché su abstractButton, poiché le voci della barra dei menu sono in genere stilizzate in modo molto diverso dai pulsanti normali (piatte, senza bordi né ombre, ecc.).
menuBarItem {
text.alignment: Qt.AlignLeft | Qt.AlignVCenter
background {
radius: 0
color: "transparent"
border.width: 0
}
hovered.background.color: "#c0c0c0"
}menuItem : ControlStyle
Proprietà raggruppate per lo styling MenuItem.
Le proprietà non impostate assumono il valore predefinito di control.
Nota: nei controlli Qt Quick, un MenuItem eredita da AbstractButton. In StyleKit, tuttavia, menuItem ricade su control anziché su abstractButton, poiché le voci di menu sono in genere stilizzate in modo molto diverso dai pulsanti normali (piatte, senza bordi o ombre proiettate, ecc.).
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"
}menuSeparator : ControlStyle
Proprietà raggruppate per lo styling MenuSeparator.
Le proprietà non impostate assumono il valore predefinito di control.
menuSeparator {
background.visible: false
indicator {
width: 188
height: 1
border.width: 0
color: "#c0c0c0"
foreground.visible: false
}
}page : ControlStyle
Proprietà raggruppate per lo styling: Page.
Le proprietà non impostate assumono il valore predefinito pane.
Si noti che le proprietà ` header ` e ` footer ` di un ` Page ` vengono in genere impostate dall'applicazione su ` ToolBar ` o ` TabBar`, e tali controlli vengono stilizzati separatamente. Per applicare uno stile alternativo a un ` ToolBar ` quando viene utilizzato all'interno di un ` Page`, utilizzare un ` 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
Proprietà raggruppate per lo styling PageIndicator.
Le proprietà non impostate assumono il valore predefinito di 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
Proprietà raggruppate per lo styling Pane.
Le proprietà non impostate assumono il valore predefinito di control.
pane {
background {
width: 200
height: 200
color: "white"
}
}popup : ControlStyle
Proprietà raggruppate per lo styling Popup.
Le proprietà non impostate assumono il valore predefinito di control.
popup {
background {
color: "white"
border.width: 1
border.color: "darkslategray"
radius: 4
}
}progressBar : ControlStyle
Proprietà raggruppate per lo styling di ProgressBar. Nel caso di una barra di avanzamento, lo stile della scanalatura viene definito tramite l’indicatore, mentre quello della traccia di avanzamento viene definito tramite il primo piano dell’indicatore.
Le proprietà non impostate assumono il valore predefinito 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
}
}
}StyleKit non fornisce una proprietà dedicata per definire lo stile dell’animazione indeterminata di una barra di avanzamento. Per modificare l’animazione, è necessario implementare invece uno sfondo dell’indicatore personalizzato 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
Proprietà raggruppate per lo styling RadioButton.
Le proprietà non impostate assumono il valore predefinito di 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
Proprietà raggruppate per lo styling RadioDelegate.
Le proprietà non impostate assumono il valore predefinito di 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
Proprietà raggruppate per lo styling RoundButton.
Le proprietà non impostate assumono il valore predefinito di abstractButton.
roundButton {
background.radius: 255
text.alignment: Qt.AlignVCenter | Qt.AlignHCenter
}scrollBar : ControlStyle
Proprietà raggruppate per lo styling: ScrollBar. Lo stile della scanalatura viene definito tramite background, mentre quello della maniglia tramite indicator.
Le proprietà non impostate assumono il valore predefinito 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
Proprietà raggruppate per lo styling ScrollIndicator. Lo stile della scanalatura viene definito tramite background, mentre quello della maniglia tramite indicator.
Le proprietà non impostate assumono il valore predefinito 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
Proprietà raggruppate per lo styling di ScrollView.
ScrollView Di per sé non ha elementi visivi a cui applicare lo stile. Le sue barre di scorrimento possono essere personalizzate separatamente tramite la proprietà scrollBar. Tuttavia, è possibile utilizzare padding per controllare lo spazio tra le barre di scorrimento e l'area dei contenuti.
Le proprietà non impostate assumono il valore predefinito specificato in ` 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
Proprietà raggruppate per lo styling SearchField.
Le proprietà non impostate assumono il valore predefinito di 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
Proprietà raggruppate per lo styling Slider. Nel caso di uno slider, lo stile della scanalatura viene definito tramite l'indicatore, mentre lo stile della traccia di avanzamento viene definito tramite il primo piano dell'indicatore.
Le proprietà non impostate assumono il valore predefinito control.
Per i cursori verticali, scambiare le proprietà ` width ` e ` height ` dei delegati pertinenti in modo che il controllo sia più alto che largo, come mostrato nel frammento di codice riportato di seguito.
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
Proprietà raggruppate per lo styling SpinBox.
Le proprietà non impostate assumono il valore predefinito 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
}
}
}Nota: al momentoè possibile posizionare i pulsanti Su e Giù solo sul lato sinistro o destro del controllo, ma non uno sopra l'altro.
swipeDelegate : ControlStyle
Proprietà raggruppate per lo styling SwipeDelegate.
Le proprietà non specificate assumono il valore predefinito di itemDelegate.
swipeDelegate {
text.alignment: Qt.AlignVCenter | Qt.AlignLeft
background {
radius: 0
color: "white"
border.width: 0
}
hovered.background.color: "#f0f0f0"
}switchControl : ControlStyle
Proprietà raggruppate per lo styling Switch.
Le proprietà non impostate assumono il valore predefinito di 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
Proprietà raggruppate per lo styling: SwitchDelegate.
Le proprietà non impostate assumono il valore predefinito di 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
Proprietà raggruppate per lo styling: TabBar.
Le proprietà non impostate assumono il valore predefinito di pane.
tabBar {
padding: 0
spacing: -1 // let tab buttons overlap slightly
background {
color: "white"
border.width: 0
}
}tabButton : ControlStyle
Proprietà raggruppate per lo styling TabButton.
Le proprietà non impostate ricorrono a abstractButton.
tabButton {
background {
radius: 0
topLeftRadius: 4
topRightRadius: 4
color: "#e8e8e8"
}
checked.background.color: "white"
}textArea : ControlStyle
Proprietà raggruppate per lo styling TextArea.
Le proprietà non impostate assumono il valore predefinito di 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
Proprietà raggruppate per lo styling TextField.
Le proprietà non impostate assumono il valore predefinito " 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
Proprietà raggruppata per l'applicazione di stili a tutti i controlli di immissione testo, inclusi TextField e TextArea.
Le proprietà non impostate assumono il valore predefinito 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
Proprietà raggruppate per lo styling ToolBar.
Le proprietà non impostate assumono il valore predefinito di pane.
toolBar {
spacing: 2
background {
radius: 0
height: 40
border.width: 1
}
}toolButton : ControlStyle
Proprietà raggruppate per lo styling ToolButton.
Le proprietà non impostate assumono il valore predefinito di abstractButton.
toolButton {
background.radius: 0
}toolSeparator : ControlStyle
Proprietà raggruppate per lo styling ToolSeparator.
Le proprietà non impostate ricorrono a control.
Per i separatori verticali, invertire i valori di ` width ` e ` height ` dei delegati pertinenti in modo che il controllo sia più alto che largo, come mostrato nel frammento di codice riportato di seguito.
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
}
}
}Documentazione del metodo
ControlStyle getControlStyle(controlType)
Restituisce l'ControlStyle per il tipo specificato controlType, oppure null, se non è stato definito alcun ControlStyle per quel tipo.
controlType può essere uno dei tipi incorporati documentati in StyleReader.controlType, oppure l’ controlType di un CustomControl.
Questa funzione può essere utilizzata, ad esempio, per leggere o scrivere una proprietà dello stile di un CustomControl in fase di esecuzione:
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 è un tipo incorporato (come StyleReader.Button), l'utilizzo, ad esempio, di myStyle.button o myStyle.getControlStyle(StyleReader.Button) per ottenere l'ControlStyle è quasi equivalente. La differenza sta nel fatto che il primo creerà in modo pigro un ControlStyle se non è ancora definito, mentre il secondo restituirà invece null. Ciò significa che, ad esempio, myStyle.button.padding = 10 è sempre sicuro, mentre myStyle.getControlStyle(StyleReader.Button).padding = 10 fallirà se myStyle.button non è stato definito nel Style.
Vedi anche 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.