Results 1 to 4 of 4

Thread: QPropertyAnimation doesnt do anything

  1. #1
    Join Date
    Jul 2011
    Posts
    42
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QPropertyAnimation doesnt do anything

    We came up with a weird problem. We have a Widget with a few buttons, when clicking on one the widget should expand down, showing a progress bar.

    The thing is that if we do:
    Qt Code:
    1. void frmCreateKeys::slotGenerateKey()
    2. {
    3. if (!validatePage())
    4. return;
    5.  
    6. /// Animate the frame, to grow and show the progress bar
    7. QPropertyAnimation animationFrame(this, "geometry");
    8. animationFrame.setDuration(300);
    9. animationFrame.setEndValue(QRect(this->pos().x()+7,this->pos().y()+30, this->width(), this->height() + 60));
    10. animationFrame.start();
    11.  
    12. ui->msgLabel->setVisible(true);
    13. ui->pBar->setVisible(true);
    14. this->repaint();
    15.  
    16. emit createKey(); // a long task
    17. }
    To copy to clipboard, switch view to plain text mode 

    it doesnt animate, meaning the widget doesnt expand down. Now if we change the animationFrame variable to be a pointer, then everything works fine.
    Qt Code:
    1. /// Animate the frame, to grow and show the progress bar
    2. QPropertyAnimation *animationFrame = new QPropertyAnimation (this, "geometry");
    To copy to clipboard, switch view to plain text mode 

    Any ideas why this could be happening?

  2. #2
    Join Date
    Jul 2011
    Location
    Italy
    Posts
    24
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QPropertyAnimation doesnt do anything

    Quote Originally Posted by superpacko View Post
    Any ideas why this could be happening?
    Yes, your QPropertyAnimation is deleted when slotGenerateKey finish.

  3. #3
    Join Date
    Jul 2011
    Posts
    42
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPropertyAnimation doesnt do anything

    yeah, i thought so, but i also thought that the animation was performed in a thread, thus copying everything to a new object that handles the animation.

    anyway, thanks for the quick response!

  4. #4
    Join Date
    Jul 2011
    Location
    Italy
    Posts
    24
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QPropertyAnimation doesnt do anything

    The animation will be deleted as it finish if you start your animation with
    Qt Code:
    1. animationFrame->start(QAbstractAnimation::DeleteWhenStopped);
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to sakya for this useful post:

    superpacko (20th July 2011)

Similar Threads

  1. Improve QPropertyAnimation on N900
    By sezaru in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 11th May 2011, 13:24
  2. QPropertyAnimation dynamic end value is this possible?
    By GuusDavidson in forum Qt Programming
    Replies: 1
    Last Post: 11th March 2011, 12:09
  3. QPropertyAnimation and QStackedLayout:functionality.
    By savaliya_ambani in forum Qt for Embedded and Mobile
    Replies: 11
    Last Post: 24th September 2010, 08:33
  4. Using QPropertyAnimation with QGraphicsPixmapItem
    By Luc4 in forum Qt Programming
    Replies: 8
    Last Post: 29th March 2010, 09:47
  5. Replies: 1
    Last Post: 8th January 2010, 12:21

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.