Window animationsedit Delete Reprint 2015-10-10 14:50:27 Tags: qt gradient animation
An application typically contains multiple animations, for example, you might want to move many graphic items at the same time or move them in a serial way.
Qanimationgroup: The animation group parent class to contain other animations so that these animations can be triggered serially or in parallel
Qsequentialanimationgroup: string Action Painting
Qparallelanimationgroup: Parallel animations
Qpropertyanimation?: Animation class, the second parameter represents a window tree, can be size, windowopacity, gemotry, and so on
1. Fade in and fade out
The constructor writes the following code:?
1? animation =NewQpropertyanimation ( This,"windowopacity");2 3Animation->setduration ( the);//Total animation Time4 5Animation->setstartvalue (1);//Start Opaque6 7Animation->setendvalue (0);//transparent when in contact8 9Animation->seteasingcurve (qeasingcurve::linear);//Gradient Time CurveTen OneConnect (animation, &qpropertyanimation::finished A -, This, [ This]{close ();});?//end of animation close window
View Code
The parameters of the Setstartvalue method and the Setendvalue method are based on the? propertyname parameter in the class constructor, which is the second argument
? Common methods:
Start: Start animation
Pause: Pausing an animation
Stop: Stop animation
Setkeyvalueat (qreal, const qvariant &), insert key data to the position specified in Parameter 1, the state of parameter 2 appears
? setcurrenttime (int): Sets the current animation time
Setdirection (Direction): Animation direction, Forward, backward
StateChanged (Qabstractanimation::state, qabstractanimation::state)?: Status Change Signal
2, the minimization of the gradual reduction?
Note: It should be used outside the window, not in the constructor
1Qpropertyanimation *minimumanimation =2 3 NewQpropertyanimation (Videowidget,"Geometry");4 5Minimumanimation->setduration ( $);6 7Minimumanimation->Setendvalue (8 9Qrect (Maptoglobal (POS ()). x () + Videocount * videowidget->width ()Ten One, Maptoglobal (POS ()). Y (),0,0) A - ); - theMinimumanimation->start ();
View Code
qt window animations