读书人

窗口自动动画片型变化大小

发布时间: 2013-01-11 11:57:35 作者: rapoo

窗口自动动画型变化大小
就像拉拽窗口一会大一会小一样,怎么实现动画形式的变大变小啊???

用了

                QPropertyAnimation *animation = new QPropertyAnimation(parent, "geometry");
animation->setDuration(3000);
animation->setStartValue(QRect(100, 100,200, 200));
animation->setEndValue(QRect(200, 100, 1000,1000));
animation->setEasingCurve(QEasingCurve::Linear);
animation->start();


结果只变化位置,不改变大小...
[解决办法]
Widget *w = new Widget;
w->show();

QPropertyAnimation *animation = new QPropertyAnimation(w, "geometry");
animation->setDuration(3000);
animation->setStartValue(QRect(100, 100,200, 200));
animation->setEndValue(QRect(200, 100, 1000,1000));
animation->setEasingCurve(QEasingCurve::Linear);
animation->start();


这段代码运行没有问题。
不知到LZ的parent到底是个什么东东。
[解决办法]
我这可以实现阿

#include <QApplication>
#include <QPropertyAnimation>

int main(int argc,char *argv[])
{
QApplication app(argc,argv);

QWidget *w = new QWidget;
w->show();

QPropertyAnimation *animation = new QPropertyAnimation(w, "geometry");
animation->setDuration(3000);
animation->setStartValue(QRect(100, 100,200, 200));
animation->setEndValue(QRect(200, 100, 1000,1000));
animation->setEasingCurve(QEasingCurve::Linear);
animation->start();

return app.exec();
}

读书人网 >QT开发

热点推荐