qt如何實現一個漸隱窗口呢(開啟的時候他是從上往下漸漸顯示)


qt如何實現一個漸隱窗口呢?就是比如說開啟的時候他是從上往下漸漸顯示的,關閉的時候從下往上漸漸小時的
http://stackoverflow.com/questions/19087822/how-to-make-qt-widgets-fade-in-or-fade-out

 

Fade In Your Widget

// w is your widget QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(this); w->setGraphicsEffect(eff); QPropertyAnimation *a = new QPropertyAnimation(eff,"opacity"); a->setDuration(350); a->setStartValue(0); a->setEndValue(1); a->setEasingCurve(QEasingCurve::InBack); a->start(QPropertyAnimation::DeleteWhenStopped);

Fade Out Your Widget

// w is your widget QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(this); w->setGraphicsEffect(eff); QPropertyAnimation *a = new QPropertyAnimation(eff,"opacity"); a->setDuration(350); a->setStartValue(1); a->setEndValue(0); a->setEasingCurve(QEasingCurve::OutBack); a->start(QPropertyAnimation::DeleteWhenStopped); connect(a,SIGNAL(finished()),this,SLOT(hideThisWidget())); // now implement a slot called hideThisWidget() to do // things like hide any background dimmer, etc.



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM