CustomControl QML Type
사용자 정의(내장되지 않은) 컨트롤의 스타일을 정의합니다. 더 보기...
| Import Statement: | import Qt.labs.StyleKit |
| Inherits: | |
| Status: | Technology preview |
이 유형은 기술 미리보기 단계에 있으며 변경될 수 있습니다.
속성
- controlType : int
상세 설명
CustomControl을 사용하면 다음의 일부가 아닌 컨트롤을 정의하고 스타일을 지정할 수 있습니다 Qt Quick Controls. 이는 활성 Style 및 Theme 에 따라 스타일을 적용해야 하는 추가 컨트롤이나 컴포넌트가 있는 경우 유용합니다.
내장된 컨트롤 유형( abstractButton, pane, slider 등)과 마찬가지로, CustomControl은 ControlStyle 을 상속받습니다. 컨트롤 유형과 암시적으로 연결되는 내장 유형과 달리, CustomControl은 controlType 을 명시적으로 설정해야 합니다. 그 외에는 작동 방식이 완전히 동일합니다.
Style 이나 Theme 은 필요한 만큼 사용자 정의 컨트롤을 정의할 수 있으며, 테마(Theme) 내의 CustomControl은 Style 내의 CustomControl과 동일한 controlType 을 가질 수 있습니다. 이는 예를 들어, slider 이 Style 과 Theme 모두에 의해 스타일이 적용되는 것과 다르지 않습니다. 대체 로직도 동일합니다.
CustomControl에 설정되지 않은 스타일 속성은 control 에 설정된 스타일로 대체됩니다.
다음 코드 조각은 사용자 정의 컨트롤의 스타일을 정의하는 방법을 보여줍니다:
// MyStyle.qml
Style {
id: style
readonly property int myControlType: 0
CustomControl {
controlType: style.myControlType
background {
width: 120
height: 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.width
implicitHeight: styleReader.background.height
color: styleReader.background.color
radius: styleReader.background.radius
Text {
font: styleReader.font
anchors.centerIn: parent
text: "ok"
}
}참고: Qt.labs 모듈의 타입은 향후 버전에서 호환성이 보장되지 않습니다.
StyleReader, ControlStyle, Style 및 StylableControls::getControlStyle()도 참조하십시오 .
속성 문서
controlType : int
이 사용자 정의 컨트롤 유형을 식별하는 고유한 정수입니다. 사용자 정의 컨트롤 구현의 ` StyleReader.controlType `에 동일한 값을 설정하여 이 스타일 정의와 연결하십시오.
사용자 정의 컨트롤 유형은 0 에서 100000 사이의 범위 내에 있어야 합니다.
StyleReader.controlType 및 StylableControls::getControlStyle()도 참조하십시오 .
© 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.