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. How do I detect the end of NumberAnimation inside transition?
QtWS25 Last Chance

How do I detect the end of NumberAnimation inside transition?

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

    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
    0
    • T Offline
      T Offline
      task_struct
      wrote on last edited by
      #2

      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
      1
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        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
        0
        • V Offline
          V Offline
          vladimir_s
          wrote on last edited by
          #4

          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
          0

          • Login

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