Qt6 topics merged with General

QML animation doesn't honor the duration parameter

  • It set up a NumberAnimation in this way:

    property real _degree: 0
    property real _time: 50
    property bool _isSpinning: true
    function move()
        _degree += 360 / 12;
    Image {
        id: imgSpin
        source: "file:///image.png"
        layer.enabled: true
        transform: Rotation {
            id: rotSpin
            origin.x: 100
            origin.y: 100
    SequentialAnimation {
        id: animStep
        NumberAnimation { target: rotSpin; property: "angle"; easing.type: Easing.Linear; to: _degree; duration: _time; }
        PauseAnimation { duration: _isSpinning ? 0 : 500 }
        onStopped: {

    This is a simplified example to show the behavior.
    Basically I have an image and I want to rotate (spin) it around 360° continuously. I need to animate it sector-by-sector (360 / 12) because I need to decide on each position whether continue or stop animation.

    It works pretty fine if the duration property is quite high, say over 50 ms per sector (i.e. 600 ms per revolution).
    But if I decrease the duration the animation doesn't follow it anymore. Below 50 ms, even if duration = 1, the actual duration is actually the same!

    Did I forget something? Is there a way to "force" the animation to honor the duration parameter?

  • Moderators

    That might be intended, although undocumented, behaviour. 50 ms is ~3 frames. There's just no sense in trying to animate something that takes shorter time than 3 frames. But I'm only guessing.

  • It can be understandable if it would just "jump" to the target position.

    Instead it seems it actually takes more time to reach the target. It completes a whole clock cycle (12 sectors for 360°) in about 550/600 ms. This leads to 550/12 = 45.8 ms for a single animation. Settings the duration to a lower value, say 10 ms, should complete the clock cycle in about 120 ms - although the "animation" will be very rough. Instead, as said, it takes the same time (550/600 ms).

  • Moderators

    Indeed, you're right. Please consider raising this on Qt interest mailing list (maybe some Qt devs will shine more light on this) and opening a bug in Qt bug tracker.

Log in to reply