CustomControl QML Type
사용자 지정(기본 제공되지 않음) 컨트롤의 스타일링을 정의합니다. 더 보기...
| Import Statement: | import Qt.labs.StyleKit |
| Inherits: |
속성
- controlType : int
상세 설명
CustomControl을 사용하면 다음과 같이 Qt Quick Controls. 이는 활성 Style 및 Theme 에 따라 스타일을 지정해야 하는 추가 컨트롤이나 컴포넌트가 있는 경우에 편리합니다.
내장 컨트롤 유형(예: abstractButton, pane, slider)과 마찬가지로 CustomControl은 ControlStyle 을 상속합니다. 컨트롤 유형에 암시적으로 연결되는 내장 유형과 달리 CustomControl은 controlType 을 명시적으로 설정해야 합니다. 그 외에는 완전히 동일한 방식으로 작동합니다.
Style 또는 Theme 은 필요한 만큼 사용자 정의 컨트롤을 정의할 수 있으며, 테마의 CustomControl은 Style 의 것과 동일한 controlType 을 가질 수 있습니다. 이는 예를 들어 slider 이 Style 과 Theme 의 스타일을 모두 적용받는 것과 다르지 않습니다. 폴백 로직은 동일합니다.
CustomControl에 설정되지 않은 모든 스타일 속성은 control 에 설정된 스타일 속성으로 폴백됩니다.
다음 코드 조각은 사용자 정의 컨트롤의 스타일을 정의하는 방법을 보여줍니다:
// MyStyle.qml Style { id: style readonly property int myControlType: 0 CustomControl { controlType: style.myControlType background { implicitWidth: 120 implicitHeight: 30 radius: 0 } hovered.background.color: "lightslategray" pressed.background.color: "skyblue" } }
그리고 다음 코드 조각은 이를 사용하는 사용자 지정 컨트롤을 구현하는 방법에 대한 예제를 보여줍니다:
// Main.qml component MyControl : Rectangle { StyleReader { id: styleReader controlType: StyleKit.style.myControlType hovered: hoverHandler.hovered pressed: tapHandler.pressed palette: app.palette } HoverHandler { id: hoverHandler } TapHandler { id: tapHandler } implicitWidth: styleReader.background.implicitWidth implicitHeight: styleReader.background.implicitHeight color: styleReader.background.color radius: styleReader.background.radius Text { font: styleReader.font anchors.centerIn: parent text: "ok" } }
참고: Qt.labs 모듈의 유형은 향후 버전에서 호환성을 보장하지 않습니다.
StyleReader, ControlStyle, Style 를참조하세요 .
속성 문서
controlType : int
이 사용자 정의 컨트롤 유형을 식별하는 고유한 정수입니다. 사용자 지정 컨트롤 구현의 StyleReader.controlType 에 동일한 값을 설정하여 이 스타일 정의에 연결합니다.
사용자 지정 컨트롤 유형은 0 ~ 100000 범위에 있어야 합니다.
StyleReader.controlType 를참조하세요 .
© 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.