Qt动画框架:动画分组示例

QParallelAnimationGroup:并行动画,组中的动画各自自行运行。

QSequentialAnimationGroup:串行动画,运行完一个下一个才运行。

    QPropertyAnimation * animation = new QPropertyAnimation(ui->w, "widgetWidth");
    animation->setDuration(3000);
    animation->setStartValue(100);
    animation->setEndValue(700);
    animation->setEasingCurve((QEasingCurve::Type)ui->comboBox->currentIndex());

    QPropertyAnimation * animation2 = new QPropertyAnimation(ui->w_2, "widgetWidth");
    animation2->setDuration(3000);
    animation2->setStartValue(100);
    animation2->setEndValue(700);
    animation2->setEasingCurve((QEasingCurve::Type)ui->comboBox->currentIndex());

    QParallelAnimationGroup *group = new QParallelAnimationGroup;
    //QSequentialAnimationGroup *group = new QSequentialAnimationGroup;

    group->addAnimation(animation);
    group->addAnimation(animation2);
    group->start(QAbstractAnimation::DeleteWhenStopped);

动画分组也是动画,也可以嵌套进分组

    QPropertyAnimation * animation = new QPropertyAnimation(ui->w, "widgetWidth");
    animation->setDuration(3000);
    animation->setStartValue(100);
    animation->setEndValue(700);
    animation->setEasingCurve((QEasingCurve::Type)ui->comboBox->currentIndex());

    QPropertyAnimation * animation2 = new QPropertyAnimation(ui->w_2, "widgetWidth");
    animation2->setDuration(3000);
    animation2->setStartValue(100);
    animation2->setEndValue(700);
    animation2->setEasingCurve((QEasingCurve::Type)ui->comboBox->currentIndex());

    QParallelAnimationGroup *group = new QParallelAnimationGroup;
    group->addAnimation(animation);
    group->addAnimation(animation2);

    QPropertyAnimation * animation3 = new QPropertyAnimation(ui->w_3, "widgetWidth");
    animation3->setDuration(3000);
    animation3->setStartValue(100);
    animation3->setEndValue(700);
    animation3->setEasingCurve((QEasingCurve::Type)ui->comboBox->currentIndex());

    QPropertyAnimation * animation4 = new QPropertyAnimation(ui->w_4, "widgetWidth");
    animation4->setDuration(3000);
    animation4->setStartValue(100);
    animation4->setEndValue(700);
    animation4->setEasingCurve((QEasingCurve::Type)ui->comboBox->currentIndex());

    QParallelAnimationGroup *group2 = new QParallelAnimationGroup;
    group2->addAnimation(animation3);
    group2->addAnimation(animation4);

    QSequentialAnimationGroup *group3 = new QSequentialAnimationGroup;
    group3->addAnimation(group);
    group3->addAnimation(group2);
    group3->start(QAbstractAnimation::DeleteWhenStopped);

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值