このページでは

StyledItem QML Type

DelegateStyle をレンダリングします。詳細...

Import Statement: import Qt.labs.StyleKit
Inherits:

Item

Status: Technology preview

この型はテクノロジープレビュー段階にあり、変更される可能性があります。

プロパティ

詳細な説明

StyledItemはDelegateStyle をレンダリングします。color 、border 、gradient 、image などのプロパティを読み取り、内部で対応する視覚要素を作成します。

DelegateStyle に設定されたdelegate がnull (デフォルト)の場合、レンダリングには自動的にStyledItemが使用されます。

任意の Item に対してカスタムdelegate を設定できます。しかし、StyledItem と組み合わせることで、オーバーレイ、アンダーレイ、またはシェーダー効果を追加しつつ、デフォルトのレンダリングを維持することができます。以下のスニペットは、デフォルトのデリゲートの上に追加の Item を描画する方法を示しています:

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

注: Qt.labsモジュール内の型は、将来のバージョンでも互換性が保証されるわけではありません。

オーバーレイ、アンダーレイ、およびシェーダー効果に関するその他の例については、「StyleKit Quick Controls Example」を参照してください。

関連項目 :DelegateStyle 、delegate 、およびdataも参照してください 。

プロパティのドキュメント

delegateStyle : DelegateStyle

このアイテムがレンダリングするDelegateStyle 。

このプロパティは必須です。StyledItem がdelegate のルートアイテムである場合、このプロパティは自動的に設定されます。しかし、カスタムデリゲート内で子アイテムとして使用される場合は、明示的に設定する必要があります。

以下のスニペットでは、デフォルトのスライダーハンドルの下に星を描画するカスタムデリゲートを使用しています。ルートアイテムはStyledItem ではないため、必須のプロパティdelegateStyle を宣言し(これは自動的に割り当てられます)、それを子要素の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 {
        // Since the root item is not a StyledItem, the following
        // required properties must be defined explicitly:
        required property DelegateStyle delegateStyle
        required property QtObject control

        implicitWidth: delegateStyle.width
        implicitHeight: delegateStyle.height
        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 {
            // Forward delegateStyle into StyledItem. StyledItem doesn't
            // use 'control' for anything, so it can be omitted.
            delegateStyle: parent.delegateStyle
        }
    }
}

「 DelegateStyle 」、「delegate 」、および「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.