PDA

View Full Version : QPropertyAnimation doesnt do anything



superpacko
20th July 2011, 15:25
We came up with a weird problem. We have a Widget with a few buttons, when clicking on one the widget should expand down, showing a progress bar.

The thing is that if we do:


void frmCreateKeys::slotGenerateKey()
{
if (!validatePage())
return;

/// Animate the frame, to grow and show the progress bar
QPropertyAnimation animationFrame(this, "geometry");
animationFrame.setDuration(300);
animationFrame.setEndValue(QRect(this->pos().x()+7,this->pos().y()+30, this->width(), this->height() + 60));
animationFrame.start();

ui->msgLabel->setVisible(true);
ui->pBar->setVisible(true);
this->repaint();

emit createKey(); // a long task
}


it doesnt animate, meaning the widget doesnt expand down. Now if we change the animationFrame variable to be a pointer, then everything works fine.


/// Animate the frame, to grow and show the progress bar
QPropertyAnimation *animationFrame = new QPropertyAnimation (this, "geometry");


Any ideas why this could be happening?

sakya
20th July 2011, 15:32
Any ideas why this could be happening?
Yes, your QPropertyAnimation is deleted when slotGenerateKey finish.

superpacko
20th July 2011, 15:59
yeah, i thought so, but i also thought that the animation was performed in a thread, thus copying everything to a new object that handles the animation.

anyway, thanks for the quick response!

sakya
20th July 2011, 16:04
The animation will be deleted as it finish if you start your animation with

animationFrame->start(QAbstractAnimation::DeleteWhenStopped);