0

I want to animate a QPushButton resize, is there a way to know when the button will be resized and what will be the final size so i can set the final value for the animation?

Thanks

Rui Sebastião
  • 855
  • 1
  • 18
  • 36
  • Try to use: void QWidget::resizeEvent(QResizeEvent * event). – Matthias Jun 24 '14 at 10:23
  • but from the doc i read that when resizeEvent is called the button already has the final geometry... – Rui Sebastião Jun 24 '14 at 10:40
  • Who sets the button size? If it is out of your control, I don't think you can predict the size. – vahancho Jun 24 '14 at 14:28
  • I think you're not telling us what really happens. Why is the button being resized? Is the button's size managed by a layout? – Kuba hasn't forgotten Monica Jun 24 '14 at 22:51
  • Ok, the button is in a vertical Layout, what i want to do is, when i hide another button in that Layout, animate the adjusting processs – Rui Sebastião Jun 24 '14 at 23:29
  • Use [`QPropertyAnimation`](http://qt-project.org/doc/qt-5/qpropertyanimation.html) and animate the [`maximumHeight`](http://qt-project.org/doc/qt-5/qwidget.html#maximumHeight-prop) (or `maximumWith`, or `maximumSize`, which ever suits your needs) property. – thuga Jun 25 '14 at 08:26

1 Answers1

0

Quick look at the Qt4 documents show a class QPropertyAnimation that can animate properties of widgets. Below is example code in qt documents itself that shows you can animate geometry and control initial and final values.

QPropertyAnimation *animation = new QPropertyAnimation(myWidget, "geometry");
animation->setDuration(10000);
animation->setStartValue(QRect(0, 0, 100, 30));
animation->setEndValue(QRect(250, 250, 100, 30));
animation->start();

Check if it works for you.

Santosh
  • 147
  • 7