(持続時間ではなく) 速度を指定し、永久にループするアニメーションをまとめようとしています。うまくいかない例を 2 つ思いつきました。
FirstTry.qml
import Qt 4.7
Rectangle {
width: 100; height: 100
Text {
text: "hello"
NumberAnimation on x {
to: 50;
loops: Animation.Infinite;
duration: 50 * Math.abs(to - from)
}
}
}
画面が狂っている間に、次の実行時警告hello
が表示されます(十分です)。
QDeclarativeExpression: Expression "(function() { return 50 * Math.abs(to - from) })" depends on non-NOTIFYable properties:
QDeclarativeNumberAnimation::to
QDeclarativeNumberAnimation::from
SecondTry.qml
import Qt 4.7
Rectangle {
width: 100; height: 100
Text {
text: "hello"
SmoothedAnimation on x {
to: 50;
loops: Animation.Infinite;
velocity: 50
}
}
}
これはもっとミステリーです -SmoothedAnimation
単純にループを拒否します! アニメーションは 1 回実行され、それで終わりです。
だから私は次の質問があります:
最初の例で速度を指定する合法的な方法はありますか? SmoothedAnimation
が から派生していることを理解NumberAnimation
しているので、C++ だけでなく QML でも可能かもしれません。
SmoothedAnimation
ループを作る方法はありますか?2 番目の例はバグで動作していませんか、それとも何か不足していますか?
これら 2 つの動作を同時に達成する他の方法はありますか?