Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    How do I detect the end of NumberAnimation inside transition?

    QML and Qt Quick
    3
    4
    9745
    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.
    • V
      vladimir_s last edited by

      How can I detect the end of NumberAnimation inside transition?

      Here is my code:

      @
      transitions:[
      Transition {
      ...
      },

          Transition {
              from: "*"
              to: "PASSIVE"
      
              ParallelAnimation{
                  NumberAnimation{
                      id: moveAnim 
                      properties:"x,y"
                      duration:1000
                      easing.type: "InOutElastic"
                      onRunningChanged: {
                            if(!moveAnim.running){
                                   console.log("End of transition!");
                                  // send signal, call js function, etc.
                            }
                      } 
                  }
      
      
              }
          }
      ]
      

      @

      This method with catching onRunningChanged and checking the state of running property works perfectly if NumberAnimation is placed inside Behavior, but doesn't seem to work inside transition. What am I doing wrong?

      1 Reply Last reply Reply Quote 0
      • T
        task_struct last edited by

        Hello,

        you can put your NumberAnimation in SequentialAnimation and use "ScriptAction":http://doc.qt.nokia.com/4.7-snapshot/qml-scriptaction.html This way ScriptEction will be executed after NumberAnimation finishes.

        "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

        • Linu...
        1 Reply Last reply Reply Quote 1
        • A
          andre last edited by

          Animations also have an running property, right? So, you can use onRunningChanged to respond to changes in the run state of an animation.

          1 Reply Last reply Reply Quote 0
          • V
            vladimir_s last edited by

            Andre, the problem is that onRunningChanged does not work if Animation is inside transition. It works if Animation is inside Behavior, but that's not what I need.

            task_struct, thank you. I already found a quick temporary solution by defining bool property, changing it in PropertyAction put in SequentialAnimation after the NumberAnimation and then catching On<property>Changed event like this:

            @
            property bool trigger: false
            onTriggerChanged: triggerChangeProc()
            ...
            Transition {
            from: "*"
            to: "PASSIVE"
            SequentialAnimation{

                        NumberAnimation{
                            properties:"x,y"
                            duration:1000
                            easing.type: "InOutElastic"
            
                        }
                        PropertyAction{
                            target:systemMessageRect; property:"trigger"; value: "true"
                        }
            
                    }
            
            
                }
            

            function triggerChangeProc(){
            //do the stuff
            }

            @

            Edit: but your suggestion seems to be much better.

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