From 93e53f351482fb15ac61f334044bb58056d81081 Mon Sep 17 00:00:00 2001 From: iaom Date: Wed, 26 Oct 2022 15:12:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=93=E6=9E=9C=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=96=87=E5=AD=97=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=B1=85?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/view/result-view-delegate.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/view/result-view-delegate.cpp b/frontend/view/result-view-delegate.cpp index 495acf0..693b4e5 100644 --- a/frontend/view/result-view-delegate.cpp +++ b/frontend/view/result-view-delegate.cpp @@ -17,7 +17,7 @@ void ResultViewDelegate::setSearchKeyword(const QString ®FindKeyWords) QSize ResultViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { QSize size = QStyledItemDelegate::sizeHint(option,index); - size.setHeight(size.height() + 10); + size.setHeight(size.height() + 50); return size; } @@ -35,7 +35,7 @@ void ResultViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &opt, opt.widget); QFontMetrics fontMetrics(opt.font); - text = fontMetrics.elidedText(text, Qt::ElideRight, textRect.width() - 5); //富余5px的宽度 + text = fontMetrics.elidedText(text, Qt::ElideRight, textRect.width() - m_textDoc->documentMargin() - 1); //富余5px的宽度 opt.text = text; painter->save(); @@ -44,11 +44,13 @@ void ResultViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op } else { m_hightLightEffectHelper->setTextColor(QBrush(opt.palette.text().color())); } - painter->translate(textRect.topLeft()); + m_textDoc->setPlainText(text); m_hightLightEffectHelper->setDocument(m_textDoc); m_hightLightEffectHelper->rehighlight(); + + painter->translate(textRect.x(), textRect.y() + (textRect.height() - fontMetrics.height()) / 2 - m_textDoc->documentMargin()); m_textDoc->drawContents(painter); painter->restore(); }