이 페이지에서

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이 렌더링에 자동으로 사용됩니다.

사용자 정의 delegate 는 어떤 Item에나 설정할 수 있습니다. 하지만 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 예제를 참조하십시오.

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.