Updating duration in Animation.Infinite loop using a slider



  • Hi I have a SequentialAnimation containing a number of ColorAnimations in an infinite loop. I want to update the duration properties in the ColorAnimations with a slider.

    ie. duration : sliderHorizontal1.value

    This works only after I restart the animation. I want the animation to change speeds while it is running as I move the slider. Is this possible? A snippet of my current code is below.

    Thanks

    @Slider {
    id: sliderHorizontal1
    x: 55
    y: 425
    minimumValue: 100
    value: 100
    maximumValue: 2000
    onValueChanged: text1.text=Math.round(value);
    }

    SequentialAnimation {
        loops:Animation.Infinite
        id: playbanner
        ColorAnimation {
            id:cA1
            target: rect1
            property: "color"
            from: "black"
            to: "white"
           duration: sliderHorizontal1.value
        }
        ColorAnimation {
            target: rect1
            property: "color"
            from: "white"
            to: "black"
            duration: sliderHorizontal1.value
        }
        ColorAnimation {
            target: rect2
            property: "color"
            from: "black"
            to: "white"
            duration: sliderHorizontal1.value
        }
        ColorAnimation {
            target: rect2
            property: "color"
            from: "white"
            to: "black"
            duration: sliderHorizontal1.value
        }
        ColorAnimation {
            target: rect3
            property: "color"
            from: "black"
            to: "white"
            duration: sliderHorizontal1.value
        }
        ColorAnimation {
            target: rect3
            property: "color"
            from: "white"
            to: "black"
            duration: sliderHorizontal1.value
        }
        ColorAnimation {
            target: rect4
            property: "color"
            from: "black"
            to: "white"
            duration: sliderHorizontal1.value
        }
        ColorAnimation {
            target: rect4
            property: "color"
            from: "white"
            to: "black"
            duration: sliderHorizontal1.value
        }
    }
    function mouseFunction(){
        if(!playbanner.running)
        playbanner.start()
        else if(playbanner.running)
        playbanner.stop()
    }@


  • The only way I have found a way around this is to stop and start the animation in a slider onValueChanged function, Unfortunately this also resets the animation to the beginning which I would prefer not to do. I'm new to Qt Quick. I'm sure there is a better way. Any help would be appreciated.
    Thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.