[Interest] Problems animating QGraphicsProxyWidget

Calogero Mauceri mauceri at actgate.com
Fri Aug 24 17:32:25 CEST 2012


Hi All,

I'm trying to animate a push button I have in my scene.
I want the button to become visible with an animation when the mouse 
enters the scene (essentially gradually changing the opacity of the 
button from 0 to 1)

The QPropertyAnimation class seems to be exactly what I need but it is 
not working with QGraphicsProxyWidget.
This is the way I'm creating the button when I initialize the interface 
of the QGraphicsView

void MyQGraphicsView::buildInterface(){
     ....
     myButton = new QPushButton(this);    // myButton  member 
QPushButton variable
     myButtonProxy = scene()->addWidget(myButton);    // myButtonProxy  
member QGraphicsProxyWidget variable
     ...
}

void MyQGraphicsView::enterEvent( QEvent * )
{
     QPropertyAnimation *animation = new QPropertyAnimation(_bt3DView, 
"opacity");
     animation->setDuration(1000);

     animation->setStartValue(0);
     animation->setEndValue(1);

     animation->start(QAbstractAnimation::DeleteWhenStopped);
}

The animation has no effect on the opacity of the button. I also tried 
for test to modify with an animation the position of the button. Well If 
I create the QPropertyAnimation using the proxy widget then the 
animation is not working, if I create it using the button itsself then 
the animation is working (see example below)

void MyQGraphicsView::enterEvent( QEvent * )
{
     // QPropertyAnimation *animation = new 
QPropertyAnimation(myButtonProxy, "pos");    // DOES NOT WORK
     QPropertyAnimation *animation = new QPropertyAnimation(myButton, 
"pos");
     animation->setDuration(1000);

     animation->setStartValue(QPointF(0,0));
     animation->setEndValue(QPointF(scene()->width()/2, 
scene()->height()/2));

     animation->start(QAbstractAnimation::DeleteWhenStopped);
}

I'm using Qt 4.7.3
Do you have any idea how to fix this issue?

Thanks in advance,
     Calogero

-- 
Calogero Mauceri
Software Engineer

Applied Coherent Technology Corporation (ACT)
www.actgate.com





More information about the Interest mailing list