Skip to content

Commit

Permalink
fix: watermark height
Browse files Browse the repository at this point in the history
// 需要等父窗口渲染完毕后,frameSize才会包含边框高度
  • Loading branch information
MrBeanCpp committed May 21, 2024
1 parent 15aae11 commit cd18869
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion watermarkwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QDebug>
#include <QPainter>
#include <QtMath>
#include <QTimer>

WatermarkWidget::WatermarkWidget(const QString& watermark, QWidget *parent)
: QWidget(parent), ui(new Ui::WatermarkWidget)
Expand All @@ -19,8 +20,13 @@ WatermarkWidget::WatermarkWidget(const QString& watermark, QWidget *parent)
this->parent = parent;
parent->installEventFilter(this); // 监听父窗口的事件(move resize)

resize(parent->size());
raise(); // 使水印在最顶层

// 需要等父窗口渲染完毕后,frameSize才会包含边框高度
QTimer::singleShot(0, this, [=](){
resize(parent->frameSize());
});

}

WatermarkWidget::~WatermarkWidget()
Expand Down

0 comments on commit cd18869

Please sign in to comment.