I need the value of slider's handle width, but even if I just copy the example code from Qt document, the debugger still tell me:
Cannot read property 'handleWidth' of null
What did I do wrong?
My code as below
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: I found a workaround in the end. Use state and propertychange will allow us to change the item's properties under the "handle" property from slider level