From 72669890c0c0f46e78a6d1325120760129f5e1f5 Mon Sep 17 00:00:00 2001 From: fengshaoxiong Date: Wed, 24 Jun 2020 15:51:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(bluetooth):=20=E5=AD=97=E4=BD=93=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E6=94=B9=E5=8F=98=E4=BB=BB=E5=8A=A1=E6=A0=8Ftips?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 字体大小变换后,需要同步更新布局 Log: 增加字体大小变换后,同步布局 Bug: https://pms.uniontech.com/zentao/bug-view-35000.html --- widgets/tipswidget.cpp | 12 ++++++++++++ widgets/tipswidget.h | 1 + 2 files changed, 13 insertions(+) diff --git a/widgets/tipswidget.cpp b/widgets/tipswidget.cpp index aaec10da3..86e6eacd5 100644 --- a/widgets/tipswidget.cpp +++ b/widgets/tipswidget.cpp @@ -78,3 +78,15 @@ void TipsWidget::paintEvent(QPaintEvent *event) break; } } + +bool TipsWidget::event(QEvent *event) +{ + if (event->type() == QEvent::FontChange) { + if (!m_text.trimmed().isEmpty()) { + setFixedSize(fontMetrics().width(m_text) + 6, fontMetrics().height()); + update(); + } + } + + return QFrame::event(event); +} diff --git a/widgets/tipswidget.h b/widgets/tipswidget.h index 9fd90a213..ff3e22e54 100644 --- a/widgets/tipswidget.h +++ b/widgets/tipswidget.h @@ -21,6 +21,7 @@ public: protected: void paintEvent(QPaintEvent *event) override; + bool event(QEvent *event) override; private: QString m_text;