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