QML animation with "speed" and endless "loops"

I am trying to assemble an animation in which I get an indication of speed (rather than duration) and which loop forever. I came up with two broken 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 warning at runtime, and helloswitches to the nuts on the screen (fairly fair).

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

It is more likely mistery - SmoothedAnimationsimply refuses a cycle! Animation is performed once, and then it.

So, I have the following questions:

Is there a legal way to indicate speed in the first example? I understand what is SmoothedAnimationderived from NumberAnimation, so perhaps this is possible in QML, and not just in C ++.

SmoothedAnimation? - ?

?

+5
3

"":

import Qt 4.7

Rectangle {
  width: 100; height: 100
  Text {
    text: "hello"
    NumberAnimation on x {
      from: 0;
      to: 50;
      loops: Animation.Infinite;
      duration: 50 * Math.abs(to - from)
    }
  }
}
+3

, , , , , , , .

SmoothedAnimation on x {
  to: 50;
  //loops: Animation.Infinite;
  velocity: 50
  onComplete: { restart (); }
}

.

+1

Even if SmoothedAnimation does not accept a loop parameter, you can put it in SequentialAnimation and apply loops to this outer cover. As an effect, your smooth animation will play continuously.

0
source

All Articles