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. [SOLVED] quick 1.1 shake animation
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] quick 1.1 shake animation

Scheduled Pinned Locked Moved QML and Qt Quick
10 Posts 3 Posters 4.7k 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.
  • S Offline
    S Offline
    sharethl
    wrote on last edited by
    #1

    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
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      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
      0
      • S Offline
        S Offline
        sharethl
        wrote on last edited by
        #3

        Could you show me how to do it ?

        Thanks

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          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
          0
          • S Offline
            S Offline
            sharethl
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              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
              0
              • D Offline
                D Offline
                dasRicardo
                wrote on last edited by
                #7

                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
                0
                • p3c0P Offline
                  p3c0P Offline
                  p3c0
                  Moderators
                  wrote on last edited by
                  #8

                  +1 @dasRicardo. Forgot the simplest way :)

                  157

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dasRicardo
                    wrote on last edited by
                    #9

                    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
                    0
                    • S Offline
                      S Offline
                      sharethl
                      wrote on last edited by
                      #10

                      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
                      0

                      • Login

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