Qtimerline Class Learning

Source: Internet
Author: User

The Qtimeline class provides a timeline for controlling animations.

Type: enum Curveshape{easeincurve,easeoutcurve,easeinoutcurve,linearcurve,sinecurve,cosinecurve} idle curve, linear curve and sin, Cos curve.

Enum Direction{forward,backward} direction before and after.

Enum State{notrunning,paused,running} runs, stops, and pauses.

Common slot: void Resume () receives the recovery signal, void setcurrenttime (int msec) receives the current time signal, void setpaused (bool paused) receives the current pause signal, and void start () receives the start signal , void Stop () receives a stop signal, and void toggledirection () receives a trigger direction signal.

Signal: Void finished () sends the completion signal, void framechanged (int frame) sends a frame change signal, void statechanged (Qtimeline::state newstate) sends a status change signal, void ValueChanged (qreal value) sends a value to change the signal

Overloaded functions: Virtual void timerevent (Qtimeevent *event)

Detailed description: Calling a regular slot makes GUI control animations very common. Depending on its duration, you can convert the millisecond as a parameter to the Qtimeline constructor, which indicates the length of time the animation was running. Then use the Setframerange () function to set the appropriate frame for this range. Finally, send the framechanged () signal to a suitable widget slot to change the widget's animation effect. When you start calling start (), Qtimeline will go into the running state and periodically regularly emit the framechanged () signal, making the signal connected to the widget's attribute values grow at a steady rate from low to high within your frame range. You can also use the Setupdatinterval () function to explicitly specify the interval for updates. Upon completion, the Qtimeline enters the norunning state and emits a finished () signal.

Example:

ProgressBar = new Qprogressbar (this); Progressbar->setrange (0, 100); //Construct a 1-second timeline with a frame range of 0-100 qtimeline *timeline = new Qtimeline (n, this); Timel Ine->setframerange (0, 100); Connect (TimeLine, SIGNAL (framechanged (int)), ProgressBar, SLOT (setValue (int)));  //Clicking the push button would start the progress bar animation pushbutton = new Qpushbutton (tr ("Start animation"), this); Connect (pushbutton, SIGNAL (clicked ()), TimeLine, SLOT (Start ())); 
The above program uses Qtimeline to set a framerange, and then sends a framechanged signal to ProgressBar, setting the value of the process. And with a push
The-button clicked () signal triggers the start () slot of the qtimeline.
You can also use Qtimeline animations in the graphics View frame, and the Qgraphicsitemanimation class uses timeline to animate qgraphicsitems.
Once the default timeline is running, from start to finish, you have to re-call start () to be able to run again, in order to enable Timeline to loop, you can tune
Use the Setloopcount () function to pass the number of times the timeline can run. The direction of the operation can also be changed, if you want to let timeline fallback run, as long as the call Setdirect
-ion () This function can be. You can also call the setpaused () function to pause the timeline during the timeline run, in order to achieve interactive control, use setcurrent-
The time () function can be used to set the position of the timeline directly.
In standard widgets, the frame interface is very useful, but qtimeline can be used to control any type of animation. The core of this function is valuefortime () this letter
The function generates a value of 0-1 at a given time, which is typically used to describe the number of steps in an animation. 0 is the first part of the animation and 1 is the last part of the animation. Run up
, Qtimeline calls Valuefortime () to generate the value (0-1) and emits a valuechanged () signal, which, by default, Valuefortime uses an interpolation
Algorithm to generate the value. You can also use the Setcurveshape () function to select predefined timeline algorithms for some classes.
By default, Qtimeline uses the Easeinout curve shape to provide a slow growth pattern. In a typical timeline, you can use Valuefortime ()
At this point the Qtimeline curve shape properties are ignored.

Qtimerline Class Learning

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.