summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qcommonstyle.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-05-03 11:57:10 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-05-06 03:48:09 +0200
commit2b99a71b2297d5356b253c7907e28e011cf6fee9 (patch)
treeb14e980fd8e250f5b318307a142f439deb855277 /src/widgets/styles/qcommonstyle.cpp
parent58df315ad11361323ed0dee125b1ee58e5958dd8 (diff)
Stylesheet: Don't ignore item check indicator styling
Amends cf52d725156811754cd4e094b0984864795d1d58, after which most indicator styling was no longer taken into account unless some other item aspects were styled. Calling the baseStyle to draw the entire item doesn't call back into the style sheet style for the indicator itself. The QCommonStyle code that breaks the item up into individual sub elements cannot be called for each element. E.g. turning off the check indicator feature changes the layout of the item. So if the indicator is styled, then we have to draw an otherwise empty item with the style sheet style, and then clip the already painted rect before calling the base style to draw text and highlighting with the correct palette. Add baseline test for QTreeView with different style sheets. Fixes: QTBUG-102820 Pick-to: 6.3 6.2 Change-Id: I1da5676cc63556230eac525bc550457ebd495a58 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/styles/qcommonstyle.cpp')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 5160243a91..717c8f986c 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -2268,7 +2268,9 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
case CE_ItemViewItem:
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
p->save();
- p->setClipRect(opt->rect);
+ // the style calling this might want to clip, so respect any region already set
+ const QRegion clipRegion = p->hasClipping() ? (p->clipRegion() & opt->rect) : opt->rect;
+ p->setClipRegion(clipRegion);
QRect checkRect = proxy()->subElementRect(SE_ItemViewItemCheckIndicator, vopt, widget);
QRect iconRect = proxy()->subElementRect(SE_ItemViewItemDecoration, vopt, widget);