diff --git a/src/plugins/find/searchresulttreeitemdelegate.cpp b/src/plugins/find/searchresulttreeitemdelegate.cpp index e294c5cd26ea1b9226836f9cb03690e28da16a13..bec2da78391415aba1c2cb8263b9c1b4f8488748 100644 --- a/src/plugins/find/searchresulttreeitemdelegate.cpp +++ b/src/plugins/find/searchresulttreeitemdelegate.cpp @@ -106,10 +106,16 @@ int SearchResultTreeItemDelegate::drawLineNumber(QPainter *painter, const QStyle painter->fillRect(lineNumberAreaRect, QBrush(isSelected ? option.palette.brush(cg, QPalette::Highlight) : option.palette.color(cg, QPalette::Base).darker(111))); - painter->setPen(isSelected ? - option.palette.color(cg, QPalette::HighlightedText) : Qt::darkGray); - painter->drawText(lineNumberAreaRect.adjusted(0, 0, -lineNumberAreaHorizontalPadding, 0), - Qt::AlignRight | Qt::AlignVCenter, QString::number(lineNumber)); + + QStyleOptionViewItemV3 opt = option; + opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; + opt.palette.setColor(cg, QPalette::Text, Qt::darkGray); + + const QStyle *style = QApplication::style(); + const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1; + + const QRect rowRect = lineNumberAreaRect.adjusted(-textMargin, 0, textMargin-lineNumberAreaHorizontalPadding, 0); + QItemDelegate::drawDisplay(painter, opt, rowRect, QString::number(lineNumber)); return lineNumberAreaWidth; }