- Qt5 C++ GUI Programming Cookbook
- Lee Zhi Eng
- 109字
- 2021-07-02 12:18:00
How to do it…
In the following example, we will learn how to add an easing curve to our animation:
- 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();
- 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();
- 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();
推薦閱讀
- Hands-On RESTful Web Services with TypeScript 3
- 慢性腎臟病診療與保健
- 謠言背后的健康真相
- 臨床神經(jīng)認(rèn)知及社會功能評估手冊
- 實(shí)用肝膽病臨床手冊
- 實(shí)用胃腸病臨床手冊
- 再生醫(yī)學(xué)基礎(chǔ)與臨床
- 牙齒健康與口腔保健手冊
- 活血化瘀方藥臨床使用指南
- 醫(yī)療損害判例評析
- 走進(jìn)孤獨(dú)的世界:為家長專業(yè)解讀自閉癥
- Learn Data Structures and Algorithms with Golang
- 眼睛怎么了:眼科醫(yī)生告訴你
- 腫瘤標(biāo)志物
- 失眠的心理學(xué)干預(yù)