summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2023-06-08 10:17:42 +0200
committerAxel Spoerl <axel.spoerl@qt.io>2023-06-08 19:29:34 +0200
commit30cf6ed32f3e38c8623cbafbb25b4ce558d370f3 (patch)
treef87e547b585d957ea268a90452eefab66f8d7ab0 /src/widgets/styles
parent9d8a04cd1fd0a0c4ec891a9497512e4bbbaead9d (diff)
Don't double draw ItemViewItems' icons in QStyleSheetStyle::drawControl
To draw a CE_ItemViewItem QStyleSheetStyle::drawControl lets parts of the element being drawn by QWindowsStyle, others by baseStyle(). If the ItemViewItem has an icon, it can lead to the icon being drawn twice: Once by QWindowsStyle, respecting options set in the stylesheet. Once by the baseStyle(), not respecting stylesheet options. When the style sheet modifies the icon's position, the icon will be drawn at this position as well as on the default position. This patch prevents an icon to be drawn by baseStyle() when it has already been drawn by the QWindowsStyle. Fixes: QTBUG-110942 Pick-to: 6.6 6.5 Change-Id: I8622dfe95bef13b196a3e38025fac1cc92f097c9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 5d0432d2e0..22a5f718ce 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -4383,6 +4383,11 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
optIndicator.backgroundBrush = Qt::NoBrush; // no background
optIndicator.text.clear();
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
// style from drawing the check indicator again (it would change how the item