还可以用QPropertyAnimation产生动画效果
下面的例子是动画打开窗口的,代码放到构造函数里
QPropertyAnimation *animation = new QPropertyAnimation(this, "geometry", this);
animation->setDuration(5000);// 五秒
animation->setStartValue(QApplication::desktop()->availableGeometry()); // 设置最终大小位置 ,这里设置的是占满桌面
QPoint pcen = QApplication::desktop()->availableGeometry().center();
QPoint off(50,50);
QRect grect(pcen - off ,pcen + off);
animation->setStartValue(grect);
animation->setEndValue(QApplication::desktop()->availableGeometry());
animation->start(QAbstractAnimation::DeleteWhenStopped);