From 304eca394aff0248b0d2a07b9a2c05dbd5234d2a Mon Sep 17 00:00:00 2001 From: Matthias Rauter Date: Wed, 8 Nov 2023 10:47:54 +0100 Subject: [PATCH] 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 --- src/widgets/styles/qstylesheetstyle.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 8bba6280b3..fb0aeab616 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -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,