QPropertyAnimation doing nothing
-
HI
I try to animate the appearance of a Widget, to be more precise a QWebView on eLinux, Qt4.6.3.
I replaced this line:ui->webGUI->setGeometry(x, y, w, h);
with this:
QPropertyAnimation animation(ui->webGUI, "geometry"); animation.setDuration(10000); animation.setStartValue(QRect(0, 0, 0, 0)); animation.setEndValue(QRect(x, y, w, h)); animation.start();
Shouldn't this animate the QWebView like "opening" from 0 to its final coordinates?
Nothing is animated. The Widget still opens directly at its End Value (pos,size).What am I doing wrong?
Thanks for any suggestion.
McL -
Hi,
You're allocating it on the stack, so as soon as your function is done, animation is destroyed.
-
@SGaist
I realized that later and I was just about to update this thread.
I now have in the constructor of the main window and in the header, class private section:QPropertyAnimation *animation;
And changed the rest to:
animation = new QPropertyAnimation(ui->webGUI, "geometry"); animation->setDuration(10000); animation->setStartValue(QRect(0, 0, 100, 30)); animation->setEndValue(QRect(x, y, w, h)); animation->start();
Still no joy!
There's still something wrong. -
You should rather start that animation once everything is constructed using e.g. a single shot QTimer with value 0. Right now you are starting your animation while the event loop hasn't even started.
-
I'm not sure I understand you correctly. This part of the code
animation = new QPropertyAnimation(ui->webGUI, "geometry"); animation->setDuration(10000); animation->setStartValue(QRect(0, 0, 100, 30)); animation->setEndValue(QRect(x, y, w, h)); animation->start();
is in an function that is called normally at runtime when everything is up and running.
-
Is webGui in a layout ?
-
It depends on what you are currently animating. If it something that needs processing before painting then you might get a performance hit.
-
OK. I changed the code to make sure there is nothing else consuming CPU power while moving. Still, specially when moving fast, edges are jagged while moving and sometimes it even jumps.
Could be the limit of the ARM CPU or the directFB graphic acceleration.
It would be better if supplying new coordinates to the FB would be synced to the frame rate, but I don't think that I can change something on that level.Too bad ..