diff options
author | Christian Ehrlicher <[email protected]> | 2025-04-25 22:01:31 +0200 |
---|---|---|
committer | Christian Ehrlicher <[email protected]> | 2025-06-21 15:52:03 +0200 |
commit | c0d8ed882fe09dd0e52a5847b45a6e2fc3a7fb87 (patch) | |
tree | 1e2a5a7c457e5f9ccec44528e180eb47ebf60194 | |
parent | 8343f050abcbb0e4f68ba1e6e769acc5ce7616b2 (diff) |
Windows11Style: draw background of item in an itemview
The background was not drawn within drawControl(CE_ItemViewItem) which
results in wrong paintings when e.g. a QTreeWidgetItem has a custom
background color.
Fix it by calling proxy()->drawPrimitive(PE_PanelItemViewItem) like it's
done in qcommonstyle for the other styles.
Pick-to: 6.10 6.9 6.8
Fixes: QTBUG-136130
Change-Id: Ifd88b8b573c1c29ccaccd58329dcf35f76a1dc19
Reviewed-by: Volker Hilsheimer <[email protected]>
-rw-r--r-- | src/plugins/styles/modernwindows/qwindows11style.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index a0bd0df09ae..953fb1618a1 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -10,6 +10,7 @@ #include <private/qcombobox_p.h> #include <qstyleoption.h> #include <qpainter.h> +#include <qpainterstateguard.h> #include <QGraphicsDropShadowEffect> #include <QLatin1StringView> #include <QtWidgets/qcombobox.h> @@ -1011,6 +1012,15 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption } break; } + case PE_PanelItemViewItem: + if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) { + if (vopt->backgroundBrush.style() != Qt::NoBrush) { + QPainterStateGuard psg(painter); + painter->setBrushOrigin(vopt->rect.topLeft()); + painter->fillRect(vopt->rect, vopt->backgroundBrush); + } + } + break; case PE_PanelItemViewRow: if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) { // this is only called from a QTreeView to paint @@ -1724,6 +1734,9 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op QRect iconRect = proxy()->subElementRect(SE_ItemViewItemDecoration, vopt, widget); QRect textRect = proxy()->subElementRect(SE_ItemViewItemText, vopt, widget); + // draw the background + proxy()->drawPrimitive(PE_PanelItemViewItem, option, painter, widget); + const QRect &rect = vopt->rect; const bool isRtl = option->direction == Qt::RightToLeft; bool onlyOne = vopt->viewItemPosition == QStyleOptionViewItem::OnlyOne || |