• 3840阅读
  • 1回复

为什么第一个动画组被忽略了呀?  要让两个动画组串着运行怎么办呀? [复制链接]

上一主题 下一主题
离线abcasg
 

只看楼主 倒序阅读 楼主  发表于: 2013-11-18
#include <QApplication>
#include <QPushButton>
#include <QPropertyAnimation>
#include <QSequentialAnimationGroup>
#include <QParallelAnimationGroup>
#include <QApplication>
#include <QPushButton>
#include <QState>
#include <QStateMachine>
#include <QSignalTransition>
#include <QPropertyAnimation>
#include <QFinalState>

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

    QPushButton button1("Animated Button");
    button1.show();
    QPushButton button2("Animated Button2");
    button2.show();
    //按钮部件1的动画
    QPropertyAnimation *animation1 = new QPropertyAnimation(&button1, "geometry");
    animation1->setDuration(2000);
    animation1->setStartValue(QRect(250, 0, 100, 30));
    animation1->setEndValue(QRect(250, 300, 100, 30));
    animation1->setEasingCurve(QEasingCurve::OutBounce);
    //按钮部件2的动画
    QPropertyAnimation *animation2 = new QPropertyAnimation(&button2, "geometry");
    animation2->setDuration(2000);
    animation2->setStartValue(QRect(400, 0, 100, 30));
    animation2->setEndValue(QRect(400, 300, 100, 30));
     animation2->setEasingCurve(QEasingCurve::OutBounce);
    //并行动画组
    QParallelAnimationGroup group;
    group.addAnimation(animation1);
    group.addAnimation(animation2);
    group.start();

    QPropertyAnimation *animation3 = new QPropertyAnimation(&button1, "geometry");
    animation3->setDuration(2000);
    animation3->setStartValue(QRect(250,300, 100, 30));
    animation3->setEndValue(QRect(450, 300, 100, 30));
    animation3->setEasingCurve(QEasingCurve::OutBounce);
    //按钮部件2的动画
    QPropertyAnimation *animation4 = new QPropertyAnimation(&button2, "geometry");
    animation4->setDuration(2000);
    animation4->setStartValue(QRect(400,300, 100, 30));
    animation4->setEndValue(QRect(600, 300, 100, 30));
     animation4->setEasingCurve(QEasingCurve::OutBounce);

     QParallelAnimationGroup group1;
     group1.addAnimation(animation3);
     group1.addAnimation(animation4);
     group1.start();


    return app.exec();
}
离线XChinux

只看该作者 1楼 发表于: 2013-11-19
将第一个动画的结束信号与第二个动画的开始方法连接起来。
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
快速回复
限100 字节
 
上一个 下一个