December 12, 2011

bkamps bkamps
Ant Farmer
115 posts

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:

  1.  BorderImage {
  2.      id: softkeyImage
  3.      source: "images/image.png"
  4.                  
  5.      SequentialAnimation {
  6.       running: softkey.state == "fadeoutin"
  7.       NumberAnimation { target: softkeyImage; property: "opacity"; to: 0.5; duration: 1000 }
  8.       NumberAnimation { target: softkeyImage; property: "opacity"; to: 1; duration: 1000 }
  9.       loops: Animation.Infinite
  10.      }                    
  11.  }

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?

4 replies

December 12, 2011

task_struct task_struct
Hobby Entomologist
344 posts

Hello,

you can achieve this by using states [doc.qt.nokia.com]

 Signature 

“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.”
- Linus Torvalds

December 12, 2011

bkamps bkamps
Ant Farmer
115 posts

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.

December 12, 2011

task_struct task_struct
Hobby Entomologist
344 posts

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

  1. SequentialAnimation {
  2.      running: softkey.state == "fadeoutin"
  3.      PropertyAction { target: softkeyImage; property: "opacity"; value: 0.5 }
  4.      PauseAnimation { duration: 1000 }
  5.      PropertyAction { target: softkeyImage; property: "opacity"; value: 1 }
  6.      PauseAnimation { duration: 1000 }
  7.      loops: Animation.Infinite
  8.  }

 Signature 

“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.”
- Linus Torvalds

December 13, 2011

bkamps bkamps
Ant Farmer
115 posts

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:

  1.   states: [
  2.       State {
  3.           name: "off"
  4.           PropertyChanges { target: image; opacity: 1}                      
  5.       }    
  6.   ]  

 
  ‹‹ QML Plugin Problem      Accessing QML components in main.qml ››

You must log in to post a reply. Not a member yet? Register here!