PDA

View Full Version : how do you use the QPropertyAnimation to effect opacity on a widget?



technoViking
10th November 2009, 18:56
Hi guys,

So what I want to do is use the QPropertyAnimation to effect the opacity of a widget to get a fade effect.

So i have the following:

note: proxy is a widget I added to the graphics scene.



QPropertyAnimation *propAnimationFade;
propAnimationFade = new QPropertyAnimation(proxy, "setOpacity");
propAnimationFade->setDuratoin(1000);
propAnimationFade->setStartValue(1.0);
propAnimationFade->setEndValue(0.0);
propAnimationFade->start();



This however doens't work.... I think the reason it doesn't work is because I'm not supplying the right field when I create the QPropertyAnimation, I use "setOpacity" and i'm not sure if thats correct or not....

Any help would be great!

aamer4yu
11th November 2009, 04:59
As you said proxy is a widget, widget has property windowOpacity.

If you use graphicsItem, property would be opacity

In your case, setOpacity is a function, not property.

technoViking
11th November 2009, 08:03
Hi thanks for your help.

I used " opacity" and it worked great...but I'm a little confused because it is a proxy widget that I add to a graphic scene.

So if opacity worked then that means it must be a graphics item correct? Some other poster said a proxy widget inherits from a graphics widget.