1
我想将一个矩形绑定到QML中的滑块。 X轴滑块的最大值是360.在180以下,矩形应该朝着变化的方向移动。在180以上,矩形应该朝相反的方向移动。QML绑定滑块值与When语句
这里是我的滑代码段,矩形
Slider {
id: xAxis
x: 60
y: 45
width: 200
value: 60
maximumValue: 360
Rectangle {
id: rect
width: parent.width/10
height: parent.height/4
color: "transparent"
border.color: "red"
border.width: 5
radius: 10
}
代码片段结合
Binding {
target: rect
property: "x"
value: (180 + (180 - xAxis.value))*(Screen.width/90)
when: xAxis.updateValueWhileDragging && xAxis.value >= 180
}
它不会在那种情况下更新。问题的根源是什么?