슬라이더 componet에 스타일 데이터에 액세스 할 수 없습니다 :QML : 나는 슬라이더의 핸들 폭의 값이 필요하지만, 난 그냥 Qt는 문서에서 예제 코드를 복사 할 경우에도, 디버거가 여전히 말해
재산을 읽을 수 없습니다 ' handleWidth 'of null
내가 뭘 잘못 했니?
import QtQuick 2.0
import QtQuick.Controls.Styles 1.4
import QtQuick.Controls 1.4
Slider {
anchors.centerIn: parent
style: SliderStyle {
groove: Rectangle {
implicitWidth: 200
implicitHeight: 8
color: "gray"
radius: 8
}
handle: Rectangle {
anchors.centerIn: parent
color: control.pressed ? "white" : "lightgray"
border.color: "gray"
border.width: 2
implicitWidth: 34
implicitHeight: 34
radius: 12
Text{
text:"test"
anchors.right:parent.right
anchors.rightMargin: styleData.handleWidth * 0.3
}
}
}
}
UPDATE 아래와 같이
가내 코드 : 나는 결국 해결 방법을 발견했다. 상태 및 속성 변경을 사용하면 슬라이더 수준의 '핸들'속성 아래에서 항목의 속성을 변경할 수 있습니다.
나는 "styleData.handleWidth"을 인쇄 할 Component.onCompleted를 사용하는 경우, 내가 가지고 : 스타일 데이터가 – Anna