Solved control the angle
-
I saw an example of qml. UI Components: Dial Control Example.
I don't understand how to caculate the angel. -
The
angle
property is read-only, instead of this you should usevalue
property. -
@IntruderExcluder
Yes. I know what you mean.
Here is the code.I just don't know "angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)" mean.Image { id: needle x: 98; y: 33 antialiasing: true source: "needle.png" transform: Rotation { id: needleRotation origin.x: 5; origin.y: 65 //! [needle angle] **angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)** Behavior on angle { SpringAnimation { spring: 1.4 damping: .15 } } //! [needle angle] } }
-
@chris_rookie said in control the angle:
I just don't know "angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)" mean.
It's a formula to calculate the angle for drawing the needle :-)
And the angle is then used to animate a Behavior:
A Behavior defines the default animation to be applied whenever a particular property value changes.
In your case the property that changes is angle which in turn is dependent on root.value
-
@Pablo-J-Rogina
Thanks for your answer.
After reading this page ```
https://doc.qt.io/qt-5/qml-qtquick-rotation.htmlI think I understand what "angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)" mean
-
@IntruderExcluder
Thanks for your answer.