Results 1 to 3 of 3

Thread: Resize QWidget using QPropertyAnimation

  1. #1
    Join Date
    Nov 2016
    Qt products

    Default Re: Resize QWidget using QPropertyAnimation

    How do you create an animation where an item scales up in size, then scales down to its original size (think of a "bouncing ball" from a top/bird's eye view). So far I have only figured out how to create a one-way animation using using x and y coordinates with positioning the widget to move from one part of the screen to other.


    My requirement is to make the central grid in the attached picture to expand and then minimize to its position (like a bouncing ball from top view). I am using the following code but there is no change in the size. Please let me know what is the right approach.

    Qt Code:
    1. int duration2 = 1000;
    2. QPropertyAnimation *animation = new QPropertyAnimation(ui->frame, "size"); //maximumSize");// "geometry");
    3. animation->setDuration(duration2);
    4. animation->setStartValue(QSize(400, 400)); //QRect(735,415,300,300));
    5. animation->setEndValue(QSize(1600, 1600));
    6. //animation->setEasingCurve(QEasingCurve::OutBounce);
    8. QPropertyAnimation *animation2 = new QPropertyAnimation(ui->graphicsView, "size");
    9. animation2->setDuration(duration2);
    10. animation2->setStartValue(QSize(400, 400)); //QRect(735,415,300,300));
    11. animation2->setEndValue(QSize(1600, 1600));//QRect(735,115,300,300));
    12. // animation2->setEasingCurve(QEasingCurve::OutBounce);
    14. QParallelAnimationGroup *group2 = new QParallelAnimationGroup;
    15. group2->addAnimation(animation);
    16. group2->addAnimation(animation2);
    17. group2->start();
    To copy to clipboard, switch view to plain text mode 

    Added after 12 minutes:

    I found out the problem, each frame here contains a grid layout and each grid contains labels holding an image of the blobs in pixmap. Now when I increase the size of the labels , it pushes the image out and the images dont expand. How do I get the images in each of the label to expand.
    Last edited by das.joyita; 9th December 2016 at 17:03.

  2. #2
    Join Date
    Jan 2006
    Graz, Austria
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Unix/X11 Windows

    Default Re: Resize QWidget using QPropertyAnimation

    If you want QLabels to scale their content see QLabel::setScaledContents().


  3. #3
    Join Date
    Nov 2016
    Qt products

    Default Re: Resize QWidget using QPropertyAnimation

    yes it works now. Thanks.

Similar Threads

  1. how to resize Qmainwindow with Qwidget ?
    By zeynepb.bil in forum Qt Programming
    Replies: 10
    Last Post: 29th September 2017, 00:48
  2. QWidget resize troubles
    By ilariari in forum Qt Programming
    Replies: 7
    Last Post: 22nd April 2015, 15:32
  3. How to disable resize in a QWidget
    By aguleo in forum Newbie
    Replies: 2
    Last Post: 17th February 2013, 21:58
  4. Replies: 15
    Last Post: 11th September 2012, 08:26
  5. Resize QWidget in QMainWindow
    By aamer4yu in forum Qt Programming
    Replies: 1
    Last Post: 8th March 2007, 13:16

Tags for this Thread


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.