Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 如何在“我的针旋转”属性上应用平滑旋转动画?_Qt_Qml - Fatal编程技术网

Qt 如何在“我的针旋转”属性上应用平滑旋转动画?

Qt 如何在“我的针旋转”属性上应用平滑旋转动画?,qt,qml,Qt,Qml,我的体重低于QML。我需要在旋转时应用平滑动画。”c++代码中的mycontroller将以频繁的间隔(比如500毫秒)给出递增的仪表值。所以我需要一个平滑的旋转过渡 Rectangle { id : gauge property real value : mycontroller.value Image { id : needle x:50 y:190 z: -2 rotation: gauge

我的体重低于QML。我需要在旋转时应用平滑动画。”c++代码中的mycontroller将以频繁的间隔(比如500毫秒)给出递增的仪表值。所以我需要一个平滑的旋转过渡

Rectangle {
   id : gauge
   property real value : mycontroller.value

   Image {
        id : needle
        x:50
        y:190
        z: -2
        rotation: gauge.value
        transformOrigin: Item.Right
        source : "qrc:/images/needle.png";
   }
}

您应该使用基于行为的方法:

Behavior on rotation { NumberAnimation { duration: 200 } }