From 001ab4c90750b309708b82d55bddef442547f808 Mon Sep 17 00:00:00 2001 From: Zhang Qipeng Date: Mon, 18 Apr 2022 18:20:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=BB=E5=8A=A1=E6=A0=8F=E8=93=9D?= =?UTF-8?q?=E7=89=99=E5=9B=BE=E6=A0=87tips=E4=BF=A1=E6=81=AF=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tips文案间隔设置错误 Log: 修复任务栏蓝牙图标tips信息显示异常的问题 Bug: https://pms.uniontech.com/bug-view-120873.html Influence: tips文案 Change-Id: I82d9e9928cc38a2dfa441ffad52b422957387fbb --- widgets/tipswidget.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/widgets/tipswidget.cpp b/widgets/tipswidget.cpp index 1bdb90add..5d0ecaa6b 100644 --- a/widgets/tipswidget.cpp +++ b/widgets/tipswidget.cpp @@ -46,11 +46,11 @@ void TipsWidget::setTextList(const QStringList &textList) int width = 0; int height = 0; for (QString text : m_textList) { - width = qMax(width, fontMetrics().width(text) + 20); + width = qMax(width, fontMetrics().width(text)); height += fontMetrics().boundingRect(text).height(); } - setFixedSize(width, height); + setFixedSize(width + 20, height); update(); } @@ -75,16 +75,18 @@ void TipsWidget::paintEvent(QPaintEvent *event) } break; case MultiLine: { - int y = 0; - if (m_textList.size() != 1) + int x = rect().x(); + int y = rect().y(); + if (m_textList.size() != 1) { + x += 10; option.setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + } for (QString text : m_textList) { int lineHeight = fontMetrics().boundingRect(text).height(); - painter.drawText(QRect(0, y, rect().width(), lineHeight), text, option); + painter.drawText(QRect(x, y, rect().width(), lineHeight), text, option); y += lineHeight; } - } - break; + } break; } }