이 페이지에서

StyledItem QML Type

DelegateStyle.. . 더보기...

Import Statement: import Qt.labs.StyleKit
Inherits:

Item

속성

상세 설명

DelegateStyle스타일드 아이템은 color, border, gradient, image 와 같은 속성을 읽고 내부적으로 해당 시각적 요소를 생성합니다.

DelegateStyle 에 설정된 delegatenull (기본값)인 경우 StyledItem이 자동으로 렌더링에 사용됩니다.

사용자 정의 delegate 는 모든 항목에 설정할 수 있습니다. 하지만 스타일드아이템과 결합하면 오버레이, 언더레이 또는 셰이더 효과를 추가하면서 기본 렌더링을 유지할 수 있습니다. 다음 스니펫은 기본 델리게이트 위에 추가 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 예제를 참조하세요.

DelegateStyle, delegate, data참조하세요 .

속성 문서

delegateStyle : DelegateStyle

이 항목이 렌더링하는 DelegateStyle.

이 속성은 필수입니다. StyledItemdelegate 의 루트 항목인 경우 자동으로 설정됩니다. 그러나 사용자 정의 델리게이트 내에서 하위 항목으로 사용되는 경우에는 명시적으로 설정해야 합니다.

다음 코드 조각은 기본 슬라이더 핸들 아래에 별을 그리는 사용자 지정 델리게이트를 사용합니다. 루트 항목이 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 {
        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
        }
    }
}

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.