QML-анимация как с «скоростью», так и с бесконечными «циклами»

I'm trying to put together an animation in which I get to specify the velocity (rather than the duration) and which loops forever. I came up with two non-working examples:

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)
    }
  }
}

I get the following runtime warning while hello goes nuts on the screen (fair enough).

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
    }
  }
}

This is more of a mistery -- SmoothedAnimation simply refuses to loop! The Animation runs once and then that's it.

So I have the following questions:

Is there a legal way to specify the velocity in the first example? I understand SmoothedAnimation is derived from NumberAnimation, so maybe it's possible in QML, not just in C++.

Is there a way to make SmoothedAnimation loop? Is the second example not working a bug or am I missing something?

Is there any other way to achieve these two behaviours at the same time?

5
задан xcvii 29 April 2011 в 14:18
поделиться