1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <qpropertyanimation.h>
void QtGLCore::showEvent(QShowEvent * event) { //缓入动画(1s)
QPropertyAnimation *animetion = new QPropertyAnimation(this, "windowOpacity");
animetion->setDuration(1000);
animetion->setStartValue(0.0);
animetion->setEndValue(1.0);
animetion->start(QPropertyAnimation::DeleteWhenStopped);
}
void QtGLCore::fadeOutAnimation() {
QPropertyAnimation *fadeAnimation = new QPropertyAnimation(this, "windowOpacity");
fadeAnimation->setDuration(1000);
fadeAnimation->setStartValue(1.0); // 从完全不透明开始
fadeAnimation->setEndValue(0.0); // 到完全透明结束
fadeAnimation->start(QPropertyAnimation::DeleteWhenStopped);
connect(fadeAnimation, &QPropertyAnimation::finished, [=]() {
this->setVisible(false);
});
}
void QtGLCore::quitApplication() { //缓出动画(500ms)
animation = new QPropertyAnimation(this, "windowOpacity");
animation->setDuration(500);
animation->setStartValue(0.0);
animation->setEndValue(1.0);
connect(animation, &QPropertyAnimation::finished, [=]() {
animation->deleteLater();
QApplication::quit();
});
animation->start(QPropertyAnimation::DeleteWhenStopped);
}
|