PDA

View Full Version : QPropertyAnimation show the Widget before start the animation



rperezalejo
13th October 2011, 02:26
Hello people I am trying to animate a Widget with a QGridLayout inside a QScrollArea and do a position animation. Here is the snap:



int h = this->myWidget->getGrid()->sizeHint().height();
this->scrollArea->setWidget(this->myWidget);

QPropertyAnimation *animation = new QPropertyAnimation(this->myWidget, QString("pos").toAscii());
animation->setDuration(2000);
animation->setEasingCurve(QEasingCurve::OutQuad);
animation->setStartValue(QPoint( 0, -h));
animation->setEndValue(QPoint(0,0));
animation->start(QAbstractAnimation::DeleteWhenStopped);



my problem is that as you can see the animation start in (0, -height) but before it begins, when i "add" the widget to the ScrollArea i get a 0,002 millisecond shot of the entire widget in the (0,0) coordinates before it start the animation in (0,-h).

I have tried to set the widget invisible, add it, and before "start" put it visible but nothing.
I don´t know who to add the widget in a x,y position directly, it seams that the "addWidget" function add it in (0,0) before the animation start in (0,-h)

any advice will be welcome