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. Why QML Animation does not support setDirection like QAbstractAnimation
Forum Updated to NodeBB v4.3 + New Features

Why QML Animation does not support setDirection like QAbstractAnimation

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 594 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.
  • S Offline
    S Offline
    stuf
    wrote on last edited by
    #1

    I want an object, need it to fellow a complex path and move as an animation. The path is included line and curve. just like a train.

    Two solution: 1. PathAnimation or 2. states with multi-animation

    Problem of solution 1: The train maybe stop at a random time-point(pause the animation), and go reverse back to the start position(play animation reversely like QAbstractAnimation ), or continue to the end point.

    So i want know any way to play PathAnimation reversely?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi! If you need more control over the animation, you can use PathInterpolator:

      main.qml

      import QtQuick 2.7
      import QtQuick.Controls 2.0
      
      ApplicationWindow {
          visible: true
          width: 400
          height: 450
          title: "Fun with paths"
          color: "darkgrey"
      
          PathInterpolator {
              id: motionPath
              path: Path {
                  PathCubic {
                      x: 350
                      y: 350
                      control1X: 350
                      control1Y: 0
                      control2X: 0
                      control2Y: 350
                  }
              }
              progress: slider.position
          }
      
          Rectangle {
              width: 50
              height: 50
              color: "orange"
              border.width: 3
              border.color: "black"
              x: motionPath.x
              y: motionPath.y
              rotation: motionPath.angle
              antialiasing: true
              Text {
                  anchors.centerIn: parent
                  text: Math.round(motionPath.progress*100) + " %"
              }
          }
      
          Slider {
              id: slider
              anchors.bottom: parent.bottom
              width: parent.width
          }
      }
      

      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