Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved RotationAnimation: how to rotate about non-center coordinates?

    QML and Qt Quick
    2
    5
    1016
    Loading More Posts
    • 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.
    • B
      bob_self last edited by

      I'm using RotationAnimation for the first time. This works fine. The image
      is 190 x 44 pixels and rotates about the center at x=95, y=22. I would like
      to have it rotate about 164, 22 instead. How can I do this with
      RotationAnimation? If it can't be done this way, what is the proper way to
      do it?

      RotationAnimation on rotation {
      from: 0
      to: 360
      duration: 3000
      direction: RotationAnimation.Clockwise
      loops: Animation.Infinite
      }

      1 Reply Last reply Reply Quote 0
      • jpnurmi
        jpnurmi last edited by jpnurmi

        import QtQuick 2.6
        import QtQuick.Window 2.2
        
        Window {
            visible: true
            width: 640
            height: 480
        
            Rectangle {
                width: 190
                height: 44
                color: "red"
                anchors.centerIn: parent
        
                transform: Rotation {
                    origin.x: 164
                    origin.y: 22
        
                    RotationAnimation on angle {
                        from: 0
                        to: 360
                        duration: 3000
                        direction: RotationAnimation.Clockwise
                        loops: Animation.Infinite
                    }
                }
            }
        }
        
        1 Reply Last reply Reply Quote 2
        • jpnurmi
          jpnurmi last edited by

          You can use QML Rotation.

          1 Reply Last reply Reply Quote 1
          • B
            bob_self last edited by

            Yes. I tried that and it works except that I don't know how to animate this solution.

            thanks,
            Bob

            1 Reply Last reply Reply Quote 0
            • jpnurmi
              jpnurmi last edited by jpnurmi

              import QtQuick 2.6
              import QtQuick.Window 2.2
              
              Window {
                  visible: true
                  width: 640
                  height: 480
              
                  Rectangle {
                      width: 190
                      height: 44
                      color: "red"
                      anchors.centerIn: parent
              
                      transform: Rotation {
                          origin.x: 164
                          origin.y: 22
              
                          RotationAnimation on angle {
                              from: 0
                              to: 360
                              duration: 3000
                              direction: RotationAnimation.Clockwise
                              loops: Animation.Infinite
                          }
                      }
                  }
              }
              
              1 Reply Last reply Reply Quote 2
              • B
                bob_self last edited by

                Yes. That's what I was looking for. Thank you!

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post