From bcf4d599fe8e57c110603e63280ac6041fcf507a Mon Sep 17 00:00:00 2001 From: chenzhe Date: Tue, 31 Dec 2019 14:12:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:The=20on-screen=20keyboard=20and=20disk=20o?= =?UTF-8?q?n=20the=20dock=20are=20not=20fully=20displayed.=20dock=E4=B8=8A?= =?UTF-8?q?=E5=B1=8F=E5=B9=95=E9=94=AE=E7=9B=98=E5=92=8C=E7=A3=81=E7=9B=98?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E6=95=B4=E6=98=BE=E7=A4=BA=E3=80=82=20bug:10?= =?UTF-8?q?498?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- widgets/tipswidget.cpp | 7 +++++++ widgets/tipswidget.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/widgets/tipswidget.cpp b/widgets/tipswidget.cpp index e6d8d01af..87ad27503 100644 --- a/widgets/tipswidget.cpp +++ b/widgets/tipswidget.cpp @@ -16,9 +16,16 @@ void TipsWidget::setText(const QString &text) update(); } +void TipsWidget::refreshFont() +{ + setFixedSize(fontMetrics().width(m_text) + 6, fontMetrics().height()); + update(); +} + void TipsWidget::paintEvent(QPaintEvent *event) { QFrame::paintEvent(event); + refreshFont(); QPainter painter(this); painter.setPen(QPen(palette().brightText(), 1)); diff --git a/widgets/tipswidget.h b/widgets/tipswidget.h index 8509a2c5c..cb5e0b61a 100644 --- a/widgets/tipswidget.h +++ b/widgets/tipswidget.h @@ -10,7 +10,8 @@ public: explicit TipsWidget(QWidget *parent = nullptr); void setText(const QString &text); - + void refreshFont(); + protected: void paintEvent(QPaintEvent *event) override;