QPropertyAnimation doing nothing
-
wrote on 2 Dec 2015, 16:11 last edited by McLion 12 Feb 2015, 16:17
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.
-
Hi,
You're allocating it on the stack, so as soon as your function is done, animation is destroyed.
wrote on 3 Dec 2015, 07:52 last edited by@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.
-
wrote on 3 Dec 2015, 08:33 last edited by
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 ?
-
wrote on 3 Dec 2015, 12:13 last edited by
No. I have the following structure:
-- QTGUI_MainWindow (class QMainWindwo)
--- centralWidget (class QWidget)
---- webGUI (class QWebView)
---- ...... all other elements -
wrote on 3 Dec 2015, 15:22 last edited by
Got it working.
Silly (and embarrassing) bug in correct calling ...Thanks anyway!
-
wrote on 3 Dec 2015, 15:45 last edited by
I'd like to open this again.
Is this known to be extremely power consuming?
Animating a Textbox or an empty WebView works acceptable.
If it's loaded with some html content it's extremely choppy, not to say unusable. -
It depends on what you are currently animating. If it something that needs processing before painting then you might get a performance hit.
-
wrote on 4 Dec 2015, 09:05 last edited by
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 ..
4/11