Мне нужно значение ширины ручки ползунка, но даже если я просто скопирую код примера из документа Qt, отладчик все равно скажет мне:
Не удается прочитать свойство 'handleWidth' из 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
}
}
}
}
ОБНОВЛЕНИЕ: в конце концов я нашел обходной путь. Использование состояния и изменения свойств позволит нам изменить свойства элемента в свойстве «дескриптор» с уровня ползунка.