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. Animation in qml
Qt 6.11 is out! See what's new in the release blog

Animation in qml

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 763 Views 1 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.
  • Q Offline
    Q Offline
    QtQmlLearner
    wrote on last edited by
    #1

    Hi,

    I am unable to perform below mentioned scenario using qml:

    I want to show movement w.r.t "X" from left to right on click. Then again right to left onclicked.

    Can any one suggest some idea how to do this?

    1 Reply Last reply
    0
    • Shrinidhi UpadhyayaS Offline
      Shrinidhi UpadhyayaS Offline
      Shrinidhi Upadhyaya
      wrote on last edited by Shrinidhi Upadhyaya
      #2

      Hi @QtQmlLearner , can you share your code or your expected output so that, we can get to know more and suggest a better solution.

      Please have a look at the below code, it some simple stuff:-

       Rectangle {
              id: rect
      
              width: 100
              height: 100
              color: "red"
      
              SmoothedAnimation {
                  id: anim
      
                  duration: 1000
                  target: rect
                  property: "x"
              }
      
              MouseArea {
                  anchors.fill: parent
                  onClicked: {
                      if(parent.x === 0) {
                          anim.to = 200;
                          anim.start();
                      } else {
                          anim.from = 200
                          anim.to = 0;
                          anim.start();
                      }
                  }
              }
          }
      

      Shrinidhi Upadhyaya.
      Upvote the answer(s) that helped you to solve the issue.

      1 Reply Last reply
      1
      • Q Offline
        Q Offline
        QtQmlLearner
        wrote on last edited by
        #3

        @Shrinidhi-Upadhyaya
        Thank you so much. This is what i was expecting.

        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