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);