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. RotationAnimation: how to rotate about non-center coordinates?
QtWS25 Last Chance

RotationAnimation: how to rotate about non-center coordinates?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 1.3k Views
  • 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 Offline
    B Offline
    bob_self
    wrote on last edited by
    #1

    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
    0
    • jpnurmiJ Offline
      jpnurmiJ Offline
      jpnurmi
      wrote on last edited by jpnurmi
      #4
      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
      2
      • jpnurmiJ Offline
        jpnurmiJ Offline
        jpnurmi
        wrote on last edited by
        #2

        You can use QML Rotation.

        1 Reply Last reply
        1
        • B Offline
          B Offline
          bob_self
          wrote on last edited by
          #3

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

          thanks,
          Bob

          1 Reply Last reply
          0
          • jpnurmiJ Offline
            jpnurmiJ Offline
            jpnurmi
            wrote on last edited by jpnurmi
            #4
            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
            2
            • B Offline
              B Offline
              bob_self
              wrote on last edited by
              #5

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

              1 Reply Last reply
              0

              • Login

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