Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Is it possible to change the animation duration after the animation starts?



  • Hi, I am using PathAnimation like the following:

                PathAnimation
                {
                    id: pathAnimation
                    target: parent
                    duration: 1000
                    running: true
                    path: pathId                   
                }
    

    After the animation starts, halfway during the animation, is it possible to change the duration? Thank you in advance



  • @QTLeearn -there may be plenty of ways to do this, I would start with trying Timer;

    
        PathAnimation {
            id: pathAnimation
            target: null // changed to 'null' so I can run the code
            duration: 5000
            running: true
            path: null // changed to 'null' so I can run the code
        }
        // for notifying initial duration rate
        Timer {
            interval: 500
            running: true
            repeat: false
            onTriggered: {
                console.log("duration is 5 seconds")
            }
        }
        // for notifying changed duration rate
        Timer {
            interval: 2500
            running: true
            repeat: true
            onTriggered: {
                pathAnimation.duration = 2500
                console.log("duration is now 2.5 seconds")
            }
        }
    }
    
    

Log in to reply