0

So I'm trying to use QPropertyAnimation on a QWidget that has been added to a QGraphicsScene and it's not working. I can't really copy and paste the code as it's intertwined with a somewhat complicated system but the summary is basically this:

A custom widget is created
CustomWidget widget;

Widget is added to a graphics scene
graphicsScene,addWidget(widget);

at some later point, one of the widget's member functions tries to create and start a QPropertyAnimation

QPropertyAnimation *anim = new QPropertyAnimation(this, "_opacity");

anim->setDuration(5000);
anim->setKeyValueAt(0, 0);
anim->setKeyValueAt(1, 1);

anim->start();

instead of a smooth animation, the property changes to the second value and stays there.

I've looked online at some related problems and their solutions, but none seem to match my situation. Does anyone know how to accomplish this?

EDIT: I discovered I just needed to make the WRITE function for _opacity call update()

augzodia
  • 47
  • 5

1 Answers1

0

I guess you are allocating QPropertyAnimation and friends on the stack instead of the heap. Note that the QPropertyAnimation object will be destructed at the end of the scope, hence no properties are changed later on.

You most likely wanted to create that object on the heap. Also see the example at: http://doc.qt.digia.com/4.7/qpropertyanimation.html

kfunk
  • 2,002
  • 17
  • 25
  • Thanks, I was going off of some example that just did everything on the stack. However, now the animation just does nothing until I click, at which point it goes to the end state. – augzodia Feb 17 '13 at 23:24