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

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();
主站蜘蛛池模板: 会宁县| 石城县| 大丰市| 陕西省| 康平县| 桂林市| 尼玛县| 琼结县| 乡宁县| 康保县| 乐东| 永昌县| 金阳县| 天柱县| 宿州市| 五常市| 阿勒泰市| 红安县| 贡嘎县| 望都县| 平邑县| 崇明县| 股票| 三台县| 肃南| 丹阳市| 咸丰县| 扶风县| 沛县| 大悟县| 西林县| 柏乡县| 滦平县| 沙河市| 乌拉特中旗| 若尔盖县| 元朗区| 泉州市| 白河县| 来宾市| 湘潭县|