官术网_书友最值得收藏!

How to do it…

In the following example, we will learn how to add an easing curve to our animation:

  1. Define an easing curve and add it to the property animation before calling the start() function:
QPropertyAnimation *animation = new QPropertyAnimation(ui->pushButton, "geometry");
animation->setDuration(3000);
animation->setStartValue(ui->pushButton->geometry());
animation->setEndValue(QRect(200, 200, 100, 50));

QEasingCurve curve;
curve.setType(QEasingCurve::OutBounce);
animation->setEasingCurve(curve);
animation->start();
  1. Call the setLoopCount() function to set how many loops you want it to repeat for:
QPropertyAnimation *animation = new QPropertyAnimation(ui->pushButton, "geometry");
animation->setDuration(3000);
animation->setStartValue(ui->pushButton->geometry());
animation->setEndValue(QRect(200, 200, 100, 50));

QEasingCurve curve;
curve.setType(EasingCurve::OutBounce);
animation->setEasingCurve(curve);
animation->setLoopCount(2);
animation->start();
  1. Call setAmplitude(), setOvershoot(), and setPeriod() before applying the easing curve to the animation:
QEasingCurve curve;
curve.setType(QEasingCurve::OutBounce);
curve.setAmplitude(1.00);
curve.setOvershoot(1.70);
curve.setPeriod(0.30);
animation->setEasingCurve(curve);
animation->start();
主站蜘蛛池模板: 清水县| 柳州市| 双鸭山市| 同心县| 新竹市| 德格县| 思茅市| 湘潭市| 泗水县| 应用必备| 达日县| 临澧县| 栖霞市| 象山县| 清徐县| 电白县| 休宁县| 揭东县| 延庆县| 利津县| 五寨县| 民县| 喀什市| 阿拉善左旗| 浪卡子县| 木兰县| 巩义市| 册亨县| 静安区| 大余县| 莱州市| 繁昌县| 大同县| 泊头市| 营口市| 安吉县| 乾安县| 微博| 贡嘎县| 天等县| 隆尧县|