5 #include <QPropertyAnimation>
11 setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
12 setAttribute(Qt::WA_TranslucentBackground);
13 setAttribute(Qt::WA_DeleteOnClose);
36 m_margin.setX(height);
56 move(rect.x() + (rect.width() - width()) / 2, rect.y() + rect.height() - 200);
60 const QPoint &point = parent->mapToGlobal(QPoint(0, 0));
61 move(point.x() + (parent->width() - width()) / 2, point.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.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
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)
void setFontMargin(int height, int width) noexcept
void setFontSize(int size)
virtual void paintEvent(QPaintEvent *event) overridefinal
static QRect currentGeometry()
#define QtFontWidth(p, t)
Font string width.
The class of the toast widget.
int timerInterval() const noexcept
TTKToastLabel(QWidget *parent=nullptr)