Draw ItemViewItem icon after the background in QStyleSheetStyle

Fixes: QTBUG-118870
Pick-to: 6.5 6.6
Change-Id: I8aad9aa3b4e7e92e96039313bda3e80281523594
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
bb10
Matthias Rauter 2023-11-08 10:47:54 +01:00
parent 52b6258ec8
commit 304eca394a
1 changed files with 4 additions and 7 deletions

View File

@ -4384,17 +4384,14 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
vopt->state & QStyle::State_Selected
? QPalette::Highlight
: QPalette::Base);
// only draw the indicator; no text or background
// only draw the indicator; no text, icon or background
optIndicator.backgroundBrush = Qt::NoBrush; // no background
optIndicator.text.clear();
optIndicator.icon = QIcon();
QWindowsStyle::drawControl(ce, &optIndicator, p, w);
// If the indicator has an icon, it has been drawn now.
// => don't draw it again.
optCopy.icon = QIcon();
// Now draw text, background, and highlight, but not the indicator with the
// base style. Since we can't turn off HasCheckIndicator to prevent the base
// Now draw text, background,icon, and highlight, but not the indicator with
// the base style. Since we can't turn off HasCheckIndicator to prevent the base
// style from drawing the check indicator again (it would change how the item
// gets laid out) we have to clip the indicator that's already been painted.
const QRect checkRect = subElementRect(QStyle::SE_ItemViewItemCheckIndicator,