Qt Forum

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

    [SOLVED] quick 1.1 shake animation

    QML and Qt Quick
    3
    10
    3745
    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.
    • S
      sharethl last edited by

      Hi,

      Could someone show me how to do shake animation?
      It is used when user type in wrong password, the text will move left and right, shake head.

      I used this code, but it is from 0 to 20, and jumps back to 0 to 20 again.

      @NumberAnimation on x {
      id: animationShake
      loops: 5
      from: 0
      to: 20
      }@

      Thanks

      1 Reply Last reply Reply Quote 0
      • p3c0
        p3c0 Moderators last edited by

        Hi,

        I guess you will need to reverse from and to values when the animation stops and then again start the animation.

        157

        1 Reply Last reply Reply Quote 0
        • S
          sharethl last edited by

          Could you show me how to do it ?

          Thanks

          1 Reply Last reply Reply Quote 0
          • p3c0
            p3c0 Moderators last edited by

            Something like this
            @
            Rectangle {
            x: 50
            ...
            NumberAnimation on x{
            id: anim
            running: true
            to: 60
            duration: 100
            onStopped: {
            if(anim.to===60) { anim.from=60; anim.to=50; } else { anim.from=50; anim.to=60 }
            start()
            }
            }
            }
            @

            157

            1 Reply Last reply Reply Quote 0
            • S
              sharethl last edited by

              Thanks, but qml 1 doesn't have onStopped,
              also, it runs forever here.

              1 Reply Last reply Reply Quote 0
              • p3c0
                p3c0 Moderators last edited by

                Hmm. onCompleted should work instead.
                Ofcourse it will, you can just include a counter and check it in onCompleted to stop the animation.

                157

                1 Reply Last reply Reply Quote 0
                • D
                  dasRicardo last edited by

                  Hmm, maybe this "here":http://qt-project.org/doc/qt-4.8/qml-sequentialanimation.html

                  **Sorry for my english :)

                  PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

                  1 Reply Last reply Reply Quote 0
                  • p3c0
                    p3c0 Moderators last edited by

                    +1 @dasRicardo. Forgot the simplest way :)

                    157

                    1 Reply Last reply Reply Quote 0
                    • D
                      dasRicardo last edited by

                      So please add [SOLVED] to your thread title.

                      **Sorry for my english :)

                      PLEASE ADD [SOLVED] TO YOUR THREAD TITLE IF IT'S SOLVED.**

                      1 Reply Last reply Reply Quote 0
                      • S
                        sharethl last edited by

                        Thanks for your help!
                        And it is working
                        [quote author="dasRicardo" date="1416903679"]Hmm, maybe this "here":http://qt-project.org/doc/qt-4.8/qml-sequentialanimation.html[/quote]

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