AbstractStylableControls QML Type
Type de base abstrait contenant les types de contrôle qui peuvent être stylisés. Plus d'informations...
| Import Statement: | import Qt.labs.StyleKit |
| Inherited By: | AbstractStyle, Style, StyleVariation, and Theme |
Propriétés
- abstractButton : ControlStyle
- applicationWindow : ControlStyle
- button : ControlStyle
- checkBox : ControlStyle
- comboBox : ControlStyle
- control : ControlStyle
- flatButton : ControlStyle
- frame : ControlStyle
- groupBox : ControlStyle
- itemDelegate : ControlStyle
- label : ControlStyle
- page : ControlStyle
- pane : ControlStyle
- popup : ControlStyle
- progressBar : ControlStyle
- radioButton : ControlStyle
- scrollBar : ControlStyle
- scrollIndicator : ControlStyle
- scrollView : ControlStyle
- slider : ControlStyle
- spinBox : ControlStyle
- switchControl : ControlStyle
- tabBar : ControlStyle
- tabButton : ControlStyle
- textArea : ControlStyle
- textField : ControlStyle
- textInput : ControlStyle
- toolBar : ControlStyle
- toolButton : ControlStyle
- toolSeparator : ControlStyle
Description détaillée
AbstractControls est un type de base abstrait. Il contient un ControlStyle pour chaque type de contrôle qui peut être stylisé par un Style, Theme, ou StyleVariation.
Les types de contrôle forment une hiérarchie dans laquelle les propriétés définies sur un type de base se propagent vers le bas aux types plus spécifiques. Par exemple, l'attribution d'un rayon de quatre à abstractButton.background.radius entraînera l'attribution d'un rayon de quatre à tous les types de boutons, tels que button, checkBox et radioButton.
Les extraits de cette page illustrent quelques-unes des propriétés clés qui peuvent être utilisées pour styliser chaque type de contrôle, mais elles ne sont en aucun cas exhaustives. De nombreuses autres propriétés sont disponibles, comme indiqué dans les documentations ControlStyle et DelegateStyle. Dans la pratique, certaines d'entre elles peuvent également être omises car le site fallback style fournit déjà des valeurs par défaut raisonnables. Cela signifie que si vous supprimez simplement une propriété de l'un des snippets, cela peut ne pas affecter son apparence, puisqu'elle sera simplement lue à partir du style de repli à la place.
Note : La compatibilité des types dans les modules Qt.labs n'est pas garantie dans les versions futures.
Documentation sur les propriétés
abstractButton : ControlStyle
Propriété groupée pour styliser tous les contrôles de type bouton, y compris Button, CheckBox, RadioButton, et Switch. Les propriétés non définies sont renvoyées à 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
Voir également les types de contrôle.
applicationWindow : ControlStyle
Propriété groupée pour le style ApplicationWindow.
Les propriétés non définies reviennent à control.
Utilisez applicationWindow pour définir la couleur d'arrière-plan de la fenêtre :
light: Theme {
applicationWindow.background.color: "#f0f0f0"
}
dark: Theme {
applicationWindow.background.color: "#404040"
}Remarque : l'application doit utiliser ApplicationWindow, et non Window, pour que cela prenne effet.
button : ControlStyle
Propriété groupée pour le style Button.
Les propriétés non définies reviennent à 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
Propriété groupée pour le style CheckBox.
Les propriétés non définies reviennent à 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
Propriété groupée pour le style ComboBox.
Les propriétés non définies reviennent à 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
Propriété groupée permettant de styliser tous les contrôles.
control est le type de base dans la hiérarchie des contrôles, et les propriétés définies ici servent de valeurs par défaut pour tous les autres types de contrôles. Par exemple, en définissant control.implicitWidth: 200, tous les contrôles auront une largeur de 200 pixels, y compris les boutons, les indicateurs de défilement et tous les autres contrôles. Il remplace également toutes les valeurs héritées d'un niveau supérieur dans la hiérarchie des styles (le Style pour un Theme, ou le fallbackStyle pour un Style), y compris les effets de survol et d'autres comportements basés sur l'état. Utilisez control avec parcimonie et préférez des types de base plus spécifiques comme abstractButton ou pane lorsque c'est possible.
control { padding: 8 background.radius: 4 }
flatButton : ControlStyle
Propriété groupée permettant de styliser les boutons plats (boutons sans arrière-plan visible dans leur état normal). Le style prendra effet pour un Button si Button.flat est défini sur true.
Les propriétés non définies reviennent à abstractButton.
flatButton { // Hide background normally, show on hover background.visible: false hovered.background.visible: true }
frame : ControlStyle
Propriété groupée pour le style Frame.
Les propriétés non définies reviennent à pane.
frame { background { color: "#fafafa" border.color: "#d0d0d0" radius: 4 } }
groupBox : ControlStyle
Propriété groupée pour le style GroupBox.
Les propriétés non définies reviennent à 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
Propriété groupée pour le style ItemDelegate.
Les propriétés non définies reviennent à control.
Remarque : dans les contrôles Qt Quick, ItemDelegate hérite de AbstractButton. Dans StyleKit, cependant, itemDelegate est rattaché à control plutôt qu'à abstractButton, car les délégués sont généralement stylisés très différemment des boutons (plats, sans bordures ni ombres portées, etc.).
itemDelegate { text.alignment: Qt.AlignVCenter | Qt.AlignLeft background { radius: 0 color: "white" border.width: 0 } hovered.background.color: "#f0f0f0" }
label : ControlStyle
Propriété groupée pour le style Label.
Les propriétés non définies reviennent à 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
Propriété groupée pour le style Page.
Les propriétés non définies reviennent à pane.
page { background { color: "white" border.width: 0 } }
pane : ControlStyle
Propriété groupée pour le style Pane.
Les propriétés non définies reviennent à control.
pane { background { implicitWidth: 200 implicitHeight: 200 color: "white" } }
popup : ControlStyle
Propriété groupée pour le style Popup.
Les propriétés non définies reviennent à control.
popup { background { color: "white" border.width: 1 border.color: "darkslategray" radius: 4 } }
progressBar : ControlStyle
Propriété groupée permettant de styliser ProgressBar. Dans le cas d'une barre de progression, la rainure est stylisée par l'indicateur, tandis que la piste de progression est stylisée par l'avant-plan de l'indicateur.
Les propriétés non définies reviennent à 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 ne fournit pas de propriété spécifique pour styliser l'animation indéterminée d'une barre de progression. Pour modifier l'animation, vous devez mettre en œuvre un indicateur personnalisé de premier plan delegate à la place :
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
Propriété groupée pour le style RadioButton.
Les propriétés non définies reviennent à 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
Propriété groupée pour le style ScrollBar. Pour une barre de défilement, la rainure est stylisée par l'indicateur, tandis que la poignée est stylisée par l'avant-plan de l'indicateur.
Les propriétés non définies reviennent à 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
Propriété groupée pour le style ScrollIndicator.
Les propriétés non définies reviennent à 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
Propriété groupée pour le style de ScrollView.
ScrollView n'a pas de délégués visuels à styliser. Ses barres de défilement peuvent être stylisées séparément grâce à la propriété scrollBar. Mais vous pouvez utiliser padding pour contrôler l'espace entre les barres de défilement et la zone de contenu.
Les propriétés non définies reviennent à 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
Propriété groupée permettant de styliser Slider. Pour une barre de défilement, la rainure est stylisée par l'indicateur, tandis que la piste de progression est stylisée par l'avant-plan de l'indicateur. Les propriétés non définies reviennent à 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
Propriété groupée pour le style SpinBox.
Les propriétés non définies sont renvoyées à 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 } } }
Remarque : il n'est actuellement possible de positionner les boutons haut et bas que sur le côté gauche ou droit du contrôle, mais pas l'un sur l'autre.
switchControl : ControlStyle
Propriété groupée pour le style Switch.
Les propriétés non définies reviennent à 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
Propriété groupée pour le style TabBar.
Les propriétés non définies reviennent à pane.
tabBar { padding: 0 spacing: -1 // let tab buttons overlap slightly background { color: "white" border.width: 0 } }
tabButton : ControlStyle
Propriété groupée pour le style TabButton.
Les propriétés non définies reviennent à abstractButton.
tabButton { background { radius: 0 topLeftRadius: 4 topRightRadius: 4 color: "#e8e8e8" } checked.background.color: "white" }
textArea : ControlStyle
Propriété groupée pour le style TextArea.
Les propriétés non définies reviennent à 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
Propriété groupée pour le style TextField.
Les propriétés non définies reviennent à 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
Propriété groupée permettant de styliser tous les contrôles de saisie de texte, y compris TextField et TextArea.
Les propriétés non définies reviennent à 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
Propriété groupée pour le style ToolBar.
Les propriétés non définies reviennent à pane.
toolBar { spacing: 2 background { radius: 0 implicitHeight: 40 border.width: 1 } }
toolButton : ControlStyle
Propriété groupée pour le style ToolButton.
Les propriétés non définies reviennent à abstractButton.
toolButton { background.radius: 0 }
toolSeparator : ControlStyle
Propriété groupée pour le style ToolSeparator.
Les propriétés non définies reviennent à 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.