- Qt5 C++ GUI Programming Cookbook
- Lee Zhi Eng
- 223字
- 2021-07-02 12:18:00
How it works...
To let an easing curve control the animation, all you need to do is define an easing curve and add it to the property animation before calling the start() function. You can also try several other types of easing curve and see which one suits you best. Here is an example:
animation->setEasingCurve(QEasingCurve::OutBounce);
If you want the animation to loop after it has finished playing, you can call the setLoopCount() function to set how many loops you want it to repeat for or set the value to -1 for an infinite loop:
animation->setLoopCount(-1);
There are several parameters that you can set to refine the easing curve before applying it to the property animation. These parameters include amplitude, overshoot, and period:
- Amplitude: The higher the amplitude, the higher the bounce or elastic spring effect that will be applied to the animation.
- Overshoot: Some curve functions will produce an overshoot (exceeding its final value) curve due to a damping effect. By adjusting the overshoot value, we are able to increase or decrease this effect.
- Period: Setting a small period value will give a high frequency to the curve. A large period will give it a small frequency.
These parameters, however, are not applicable to all curve types. Please refer to the Qt documentation to see which parameter is applicable to which curve type.