Possible Duplicate:
Qt - There is a bug in QPropertyAnimation?
I wanted to animate the QWidget maximumWidth in order to change thd widgets size in a layout with animation, but it does not work. I have tried to do the following:
QPropertyAnimation *animation1 = new QPropertyAnimation(m_textEditor2, "maximumWidth");
animation1->setStartValue(0);
animation1->setEndValue(100);
animation1->start();
EDIT: For minimumWidth property the animation works, but for maximumWidth - no. Thus I have opened a bug on their bugreport site: here.
Your problem is just that maximumWidth isn't a very good property to use for animation, since it doesn't directly translate to the Widget's actual size. You better use geometry
which gives a better effect; like this for example, it animates a QTextEdit
:
class QtTest : public QMainWindow
{
Q_OBJECT
public:
QtTest()
{
m_textEdit = new QTextEdit(this);
};
protected:
QTextEdit *m_textEdit;
virtual void showEvent ( QShowEvent * event )
{
QWidget::showEvent(event);
QPropertyAnimation *animation = new QPropertyAnimation(m_textEdit, "geometry");
animation->setDuration(10000);
animation->setStartValue(QRect(0, 0, 100, 30));
animation->setEndValue(QRect(0, 0, 500, 30));
animation->start();
}
};
精彩评论