#include "faderqlabel.h"
#include <QGraphicsOpacityEffect>
#include <QPropertyAnimation>
#include <QTimer>
FaderQLabel::FaderQLabel(QWidget *parent, int timeFadeIn, int timeFadeOut, int fadeOutAfter) : QLabel(parent) {
this->timeFadeIn = timeFadeIn;
this->timeFadeOut = timeFadeOut;
QTimer *fadeOutTimer = new QTimer(this);
connect(fadeOutTimer, SIGNAL(timeout()), this, SLOT(fadeOut()));
fadeOutTimer->start(fadeOutAfter);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// SLOT FADE_OUT
void FaderQLabel::fadeOut() {
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect(this);
this->setGraphicsEffect(effect);
QPropertyAnimation *anim = new QPropertyAnimation(this);
anim->setPropertyName("opacity");
anim->setTargetObject(effect);
anim->setDuration(timeFadeOut);
anim->setStartValue(1.0);
anim->setEndValue(0.0);
anim->setEasingCurve(QEasingCurve::OutQuad);
anim->start(QAbstractAnimation:
eleteWhenStopped);
}
Bookmarks