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. Updating duration in Animation.Infinite loop using a slider
Forum Updated to NodeBB v4.3 + New Features

Updating duration in Animation.Infinite loop using a slider

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 597 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.
  • J Offline
    J Offline
    jruxton
    wrote on last edited by
    #1

    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()
    }@
    
    1 Reply Last reply
    0
    • J Offline
      J Offline
      jruxton
      wrote on last edited by
      #2

      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

      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