#include "bird.h" #include <QtGui/QApplication> #include <QtGui/qlabel.h> #include <QPixmap> #include <QPropertyAnimation> #include <qparallelanimationgroup.h> int main(int argc, char *argv[]) { QApplication a(argc, argv); // bird w; // w.show(); // return a.exec(); QWidget* w = new QWidget(); w->resize(300,400); QPixmap birding = QPixmap("b1.jpg").scaled(100,123); QLabel *bird_1 = new QLabel(w); QLabel *bird_2 = new QLabel(w); bird_1->setPixmap(birding); bird_2->setPixmap(birding); bird_1->setHidden(1); QPropertyAnimation *anm1=new QPropertyAnimation(bird_1,"pos"); anm1->setDuration(2000); anm1->setStartValue(QPoint(0,360)); anm1->setEndValue(QPoint(210,0)); anm1->setEasingCurve(QEasingCurve::OutInElastic); QPropertyAnimation *anm2=new QPropertyAnimation(bird_2,"pos"); anm2->setDuration(2000); anm2->setStartValue(QPoint(210,360)); anm2->setEndValue(QPoint(0,0)); anm2->setEasingCurve(QEasingCurve::OutInElastic); QParallelAnimationGroup group; group.addAnimation(anm1); group.addAnimation(anm2); group.start(); bird_1->move(-40,-40); bird_2->move(-40,-40); w->show(); a.exec(); }