Behind-the-scenes hero of the QT animation effect: qtimeline

Source: Internet
Author: User

 

In fact, the essence of an animation is to display an image at a certain interval. When the interval is short, the human eye will not feel it, and the animation will see continuous images. Qt provides a good time control class qtimeline for developers who develop animation effects.

 

The simplest usage of qtimeline is

 

1 qtimeline timeline = new qtimeline (1000);

2 timeline-> setframerange (0,100);

3 connect (timeline, signal (Framechanged(INT), yourobj, slot (yourobjslot (INT )));

4 Timeline-> Start ();

 

Explanation:

 

1. The duration of the created timeline. The parameter value is the number of milliseconds, and 1000 is 1 second.

2. The range of output values created in this timeline. That is, the range of parameter values transmitted from the framechanged signal in the third line.

3. the default interval of qtimeline is 40 ms (that is, 25 frames per second). A framechanged () signal is sent at each interval, connect the signal to the object and slot where you can control the animation effect.

4. After timeline is started, the framechanged () signal at each interval can be sent normally.

 

 

Of course, there are some complicated parameter settings to better control your effect.

 

Setloopcount(INT count) This function controls the number of animation repetitions. The default value is 1. If it is set to 0, it indicates an infinite loop.

Setupdateinterval(INT interval) This function is used to control the animation update interval.

 

After the duration set by qtimeline passes, a finished () signal will be sent accordingly. you can do some scanning after receiving this signal.

 

 

There is also a special option:

 

Setcurveshape(Curveshape shape), which is used to control a variation rule of the output values at intervals. The existing options of curveshage are:

 

Qtimeline: easeincurve0the value starts growing slowly, then increases in speed.

Qtimeline: easeoutcurve1the value starts growing steadily, then ends slowly.

Qtimeline: easeinoutcurve2the value starts growing slowly, then runs steadily, then grows slowly again.

Qtimeline: linearcurve3the value grows linearly (e.g., if the duration is 1000 MS, the value at time 500 MS is 0.5 ).

Qtimeline: sinecurve4the value grows sinusoidally.

Qtimeline: cosinecurve5the value grows cosinusoidally.

 

2 is the default value. Even if this option is not available, if only the uniform number is output (option 3), we can perform secondary processing on the data by ourselves to generate the number of any rule we want.

 

 

Using qtimeline, we can easily achieve some image hiding effects. You only need to display a fixed position in different stages of the image hiding process after each interval. Here is a good example. In just over 300 lines, it may not take long for you to read

 

Http://qt.gitorious.org/qt-labs/graphics-dojo/trees/master/genie

 

 

We have also contributed to www.cuteqt.com to communicate with each other :)

 

(The attachment cannot be uploaded. The example is not pasted)

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.