Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML animation doesn't honor the duration parameter
Forum Updated to NodeBB v4.3 + New Features

QML animation doesn't honor the duration parameter

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 528 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    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;
        animStep.start();
    }
    
    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: {
            move()
        }
    }
    

    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?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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.

      (Z(:^

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mark81
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          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.

          (Z(:^

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved