StyledItem QML Type
Rend une page DelegateStyle. Plus....
| Import Statement: | import Qt.labs.StyleKit |
| Inherits: |
Propriétés
- delegateStyle : DelegateStyle
Description détaillée
StyledItem effectue le rendu d'une page DelegateStyle. Il lit les propriétés telles que color, border, gradient, et image, et crée les éléments visuels correspondants en interne.
Si le delegate défini sur un DelegateStyle est null (par défaut), StyledItem sera automatiquement utilisé pour le rendu.
Un delegate personnalisé peut être attribué à n'importe quel élément. Mais combiné à un StyledItem, vous pouvez conserver le rendu par défaut tout en ajoutant des effets de superposition, de sous-couche ou d'ombrage. L'extrait suivant montre comment dessiner un élément supplémentaire au-dessus du délégué par défaut :
Style { component Star : Shape { id: star property color color ShapePath { fillColor: star.color scale: Qt.size(star.width, star.height) PathMove { x: 0.50; y: 0.00 } PathLine { x: 0.59; y: 0.35 } PathLine { x: 0.97; y: 0.35 } PathLine { x: 0.66; y: 0.57 } PathLine { x: 0.78; y: 0.91 } PathLine { x: 0.50; y: 0.70 } PathLine { x: 0.22; y: 0.91 } PathLine { x: 0.34; y: 0.57 } PathLine { x: 0.03; y: 0.35 } PathLine { x: 0.41; y: 0.35 } PathLine { x: 0.50; y: 0.00 } } } button { background.delegate: StyledItem { width: parent.width height: parent.height // Draw a star on top the default rendering Star { anchors.fill: parent color: "gold" } } } }
Note : La compatibilité des types dans les modules Qt.labs n'est pas garantie dans les versions futures.
Pour plus d'exemples de superpositions, de sous-couches et d'effets d'ombrage, voir l'exemple StyleKit.
Voir également DelegateStyle, delegate, et data.
Documentation sur les propriétés
delegateStyle : DelegateStyle
Le site DelegateStyle que cet élément rend.
Cette propriété est obligatoire. Lorsque StyledItem est l'élément racine d'un delegate, elle est définie automatiquement. Mais lorsqu'il est utilisé comme enfant à l'intérieur d'un délégué personnalisé, il doit être défini explicitement.
L'extrait suivant utilise un délégué personnalisé qui dessine une étoile sous la poignée du curseur par défaut. Comme l'élément racine n'est pas un StyledItem, il déclare une propriété obligatoire delegateStyle (qui est attribuée automatiquement) et la transmet à l'enfant StyledItem:
Style { component Star : Shape { id: star property color color ShapePath { fillColor: star.color scale: Qt.size(star.width, star.height) PathMove { x: 0.50; y: 0.00 } PathLine { x: 0.59; y: 0.35 } PathLine { x: 0.97; y: 0.35 } PathLine { x: 0.66; y: 0.57 } PathLine { x: 0.78; y: 0.91 } PathLine { x: 0.50; y: 0.70 } PathLine { x: 0.22; y: 0.91 } PathLine { x: 0.34; y: 0.57 } PathLine { x: 0.03; y: 0.35 } PathLine { x: 0.41; y: 0.35 } PathLine { x: 0.50; y: 0.00 } } } slider.handle.delegate: Item { required property DelegateStyle delegateStyle implicitWidth: delegateStyle.implicitWidth implicitHeight: delegateStyle.implicitHeight width: parent.width height: parent.height scale: delegateStyle.scale rotation: delegateStyle.rotation visible: delegateStyle.visible // Draw a star underneath the default handle delegate Star { width: parent.width * 2 height: parent.height * 2 anchors.centerIn: parent color: "gold" } StyledItem { delegateStyle: parent.delegateStyle } } }
Voir également DelegateStyle, delegate, et data.
© 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.