[Interest] animation problems
Nurmi J-P
jpnurmi at digia.com
Mon Nov 25 15:30:21 CET 2013
On 25 Nov 2013, at 14:57, Graham Labdon <Graham.Labdon at avalonsciences.com> wrote:
> Hi
> I am trying to animate the movement of one of my widgets
> I have a simple Qt app consists of a main window with a label (done in QDesigner)
> The code to move the label is
> QPropertyAnimation animation(ui.label,"geometry");
> animation.setDuration(10000);
> animation.setStartValue(ui.label->rect());
> QRect end = QRect(ui.label->rect().x() - 10,ui.label->y() - 10,ui.label->rect().width(),ui.label->rect().height());
> animation.setEndValue(end);
> animation.start();
>
> Now this does move the label but it is move instantly whereas I thought that by specifying a duration , this would be how long it took to do the animation.
>
> I would be grateful if some could explain what I am doing wrong
Hi, try allocating the animation on the heap so that it won’t get immediately destructed according to the normal C++ scoping rules.
QPropertyAnimation *animation = new QPropertyAnimation(ui.label,"geometry”);
…
animation->start(QAbstractAnimation::DeleteWhenStopped);
--
J-P Nurmi
More information about the Interest
mailing list