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

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();
主站蜘蛛池模板: 山东省| 华亭县| 买车| 本溪| 湛江市| 雅江县| 连南| 南汇区| 蓬安县| 高雄市| 游戏| 本溪| 遵义县| 威信县| 翁牛特旗| 徐汇区| 柘荣县| 东辽县| 开原市| 牙克石市| 瑞昌市| 绥芬河市| 昆山市| 明星| 澎湖县| 阿图什市| 天台县| 安龙县| 化州市| 交城县| 麦盖提县| 临朐县| 赤城县| 河池市| 杭锦后旗| 和顺县| 共和县| 金阳县| 万载县| 莒南县| 赞皇县|