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

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();
主站蜘蛛池模板: 皮山县| 晋江市| 芷江| 台东县| 文安县| 全州县| 望江县| 湾仔区| 宁远县| 山阳县| 文成县| 永胜县| 东乌珠穆沁旗| 福建省| 南丰县| 西吉县| 西丰县| 三门峡市| 曲麻莱县| 苏尼特左旗| 罗山县| 叙永县| 碌曲县| 根河市| 孙吴县| 太和县| 伊春市| 宁安市| 香港 | 中阳县| 湾仔区| 贺兰县| 博客| 鹿泉市| 庄浪县| 普兰县| 天水市| 马关县| 仪陇县| 四会市| 陕西省|