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


  • Lifetime Qt Champion

    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.


  • Lifetime Qt Champion

    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.


  • Lifetime Qt Champion

    Is webGui in a layout ?



  • No. I have the following structure:
    -- QTGUI_MainWindow (class QMainWindwo)
    --- centralWidget (class QWidget)
    ---- webGUI (class QWebView)
    ---- ...... all other elements



  • Got it working.
    Silly (and embarrassing) bug in correct calling ...

    Thanks anyway!



  • 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.


  • Lifetime Qt Champion

    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 ..


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.