5 #include <QPropertyAnimation>
11 setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
12 setAttribute(Qt::WA_TranslucentBackground);
13 setAttribute(Qt::WA_DeleteOnClose);
56 move((windowSize.width() - width()) / 2, windowSize.height() - 200);
60 const QPoint &globalPoint = parent->mapToGlobal(QPoint(0, 0));
61 move(globalPoint.x() + (parent->width() - width()) / 2, globalPoint.y() + (parent->height() - height()) / 2);
68 const QFontMetrics ftm(
m_font);
70 QLabel::setText(text);
77 QPropertyAnimation *animation =
new QPropertyAnimation(
this,
"windowOpacity",
this);
79 animation->setStartValue(1);
80 animation->setEndValue(0);
83 connect(animation, SIGNAL(
finished()), SLOT(close()));
91 QPainter painter(
this);
92 painter.setRenderHint(QPainter::Antialiasing);
93 painter.setPen(Qt::NoPen);
94 painter.setBrush(QColor(0, 0, 0, 175));
95 painter.drawRoundedRect(rect(), 6, 6);
97 painter.setPen(QColor(255, 255, 255));
98 painter.drawText(rect(), Qt::AlignCenter, text());
void popup(QWidget *parent=nullptr)
void setText(const QString &text)
int timerInterval() const
void setFontSize(int size)
virtual void paintEvent(QPaintEvent *event) overridefinal
#define QtFontWidth(p, t)
Font string width.
The class of the toast widget.
void setFontMargin(int height, int width)
static QRect screenGeometry(int index=0)
TTKToastLabel(QWidget *parent=nullptr)