//Window Fade effect
voidMainwindow::closewindowanimation ()//Close Window Effect{qpropertyanimation*animation =NewQpropertyanimation ( This,"windowopacity"); Animation->setduration ( -); Animation->setstartvalue (1); Animation->setendvalue (0); Animation-start (); Connect (animation,qpropertyanimation::finished, This, close);}voidmainwindow::startanimation () {qpropertyanimation*animation =NewQpropertyanimation ( This,"windowopacity"); Animation->setduration ( -); Animation->setstartvalue (0); Animation->setendvalue (1); Animation-start ();}
//Window Shake effect
voidMainwindow::shakewindow () {qpropertyanimation*animation =NewQpropertyanimation ( This,"Geometry"); Animation->setduration ( -); Animation->setkeyvalueat (0, Qrect (Qpoint ( This->framegeometry (). x ()-3, This->framegeometry (). Y ()), This-size ())); Animation->setkeyvalueat (0.1, Qrect (Qpoint ( This->framegeometry (). x () +6, This->framegeometry (). Y ()), This-size ())); Animation->setkeyvalueat (0.2, Qrect (Qpoint ( This->framegeometry (). x ()-6, This->framegeometry (). Y ()), This-size ())); Animation->setkeyvalueat (0.3, Qrect (Qpoint ( This->framegeometry (). x () +6, This->framegeometry (). Y ()), This-size ())); Animation->setkeyvalueat (0.4, Qrect (Qpoint ( This->framegeometry (). x ()-6, This->framegeometry (). Y ()), This-size ())); Animation->setkeyvalueat (0.5, Qrect (Qpoint ( This->framegeometry (). x () +6, This->framegeometry (). Y ()), This-size ())); Animation->setkeyvalueat (0.6, Qrect (Qpoint ( This->framegeometry (). x ()-6, This->framegeometry (). Y ()), This-size ())); Animation->setkeyvalueat (0.7, Qrect (Qpoint ( This->framegeometry (). x () +6, This->framegeometry (). Y ()), This-size ())); Animation->setkeyvalueat (0.8, Qrect (Qpoint ( This->framegeometry (). x ()-6, This->framegeometry (). Y ()), This-size ())); Animation->setkeyvalueat (0.9, Qrect (Qpoint ( This->framegeometry (). x () +6, This->framegeometry (). Y ()), This-size ())); Animation->setkeyvalueat (1, Qrect (Qpoint ( This->framegeometry (). x ()-3, This->framegeometry (). Y ()), This-size ())); Animation-start ();}
//Mouse Move window effect
voidMainwindow::mousepressevent (Qmouseevent *Event){ if(Event->button () = =Qt::leftbutton) {Startpos=Event->globalpos ()- This-framegeometry (). TopLeft (); Qdebug ()<<Event->globalpos () << This->framegeometry (). TopLeft () <<startpos; } Else if(Event->button () = =Qt::middlebutton) closewindowanimation (); Else if(Event->button () = =Qt::rightbutton) Shakewindow ();}voidMainwindow::mousemoveevent (Qmouseevent *Event){ if(Event->buttons () = = Qt::leftbutton &&startpos.y () < +) {Endpos=Event->globalpos ()-startpos; Qdebug ()<<Endpos; This-Move (Endpos); } //Qdebug () <<event->pos (). x ();}
QT window fade effect, window shake effect, mouse move window