BorderImage: switch between half and full opacity



  • I want to toggle a BorderImage between half and full opacity. For now I have used a SequentialAnimation:

    @
    BorderImage {
    id: softkeyImage
    source: "images/image.png"

     SequentialAnimation {
      running: softkey.state == "fadeoutin"
      NumberAnimation { target: softkeyImage; property: "opacity"; to: 0.5; duration: 1000 }
      NumberAnimation { target: softkeyImage; property: "opacity"; to: 1; duration: 1000 }
      loops: Animation.Infinite
     }                     
    

    }
    @

    Because our embedded device is too slow I want to remove the animation and just switch between half and full opacity. How to do this easily?



  • Hello,

    you can achieve this by using "states":http://doc.qt.nokia.com/latest/qdeclarativestates.html



  • Yes, as you can see i'm using state already in the SequentialAnimation. I want to replace this animation and maybe start a timer that switches between half and full opacity without animations.



  • You only start an animation using property binding. But in you case I think this is better. Try this:

    @
    SequentialAnimation {
    running: softkey.state == "fadeoutin"
    PropertyAction { target: softkeyImage; property: "opacity"; value: 0.5 }
    PauseAnimation { duration: 1000 }
    PropertyAction { target: softkeyImage; property: "opacity"; value: 1 }
    PauseAnimation { duration: 1000 }
    loops: Animation.Infinite
    }
    @



  • Thanks task_struct, this seems to work. I'm going to try it on the target to check the load. I also added an "off" state to set the image to full opacity when the animation is done:

    @
    states: [
    State {
    name: "off"
    PropertyChanges { target: image; opacity: 1}
    }
    ]

    @


Log in to reply
 

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