diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-10-23 12:40:05 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-10-24 14:20:35 +0200 |
commit | 16e0e7c779fea47c52a291f175654e6929fa8987 (patch) | |
tree | 6d4ff0589411c3c84e5e0f58bae673fecf092854 /src/widgets/styles | |
parent | 94039c9a6a700d65f915171067852310ff1ae62b (diff) |
QTreeView: fix drawing of background for alternate rows
After f4976f86cd265d7505da449dafe15c51e3c8cdc0 we never called the style
to draw the background of rows, unless ShowDecorationSelected was set.
This broke rendering of alternate row backgrounds, as painting that
background for the item's decoration was done by the style function that
was no longer called.
QStyleOptionViewItem::showDecorationSelected should store the value from
the widget's style and be used by the style when rendering. This avoids
that a style sheet is ignored when we are already in the virtual table
of the parent style. However, in that style option we conflate both the
style hint, and whether the entire row should be selected when the
selection behavior is SelectRow (as we then need to draw selection in
the first column all the way to the second column, not just around the
text).
To fix this, override the showDecorationSelected back to the style hint
value while we are only painting the background, and reset it back
before calling the delegate to draw the rest (including the selection).
This reverts f4976f86cd265d7505da449dafe15c51e3c8cdc0.
Fixes: QTBUG-106227
Pick-to: 6.4 6.2
Change-Id: I5c1ecdf0a0e07b156f35f4e5614593a984754a34
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 2cb9bc00ba..657f540324 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -657,7 +657,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active)) cg = QPalette::Inactive; - if ((vopt->state & QStyle::State_Selected) && proxy()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, opt, widget)) + if ((vopt->state & QStyle::State_Selected) && vopt->showDecorationSelected) p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight)); else if (vopt->features & QStyleOptionViewItem::Alternate) p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase)); |