summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qcommonstyle.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-03-20 20:09:48 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-04-04 19:23:37 +0200
commit7763b83c4cb16f9e6ed4dc278f0804bdde42075e (patch)
treec65661884097a90477e7537a9fb2089897ada6fd /src/widgets/styles/qcommonstyle.cpp
parentb932f798a271f1301026b8878b12310df8448c44 (diff)
Widgets/Styles: pass correct style option struct to subelements
QHeaderView is using QStyleOptionHeaderV2 which should later be used in the subelements drawings. But since the subelement rect must be adjusted, a copy is done - sadly only to QStyleOptionHeader so we're loosing the V2 information. Therefore explicitly check if it's a V2 and copy it over to the correct structure. Pick-to: 6.5 6.2 Fixes: QTBUG-97571 Change-Id: I1482f118e2114cd6ef21c2a800785bd9910c1c5b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/widgets/styles/qcommonstyle.cpp')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index f4a8d1f1ea..28731aaca1 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -2183,7 +2183,13 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
QRegion clipRegion = p->clipRegion();
p->setClipRect(opt->rect);
proxy()->drawControl(CE_HeaderSection, header, p, widget);
- QStyleOptionHeader subopt = *header;
+ // opt can be a QStyleOptionHeaderV2 and we must pass it to the subcontrol drawings
+ QStyleOptionHeaderV2 subopt;
+ QStyleOptionHeader &v1Copy = subopt;
+ if (auto v2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(opt))
+ subopt = *v2;
+ else
+ v1Copy = *header;
subopt.rect = subElementRect(SE_HeaderLabel, header, widget);
if (subopt.rect.isValid())
proxy()->drawControl(CE_HeaderLabel, &subopt, p, widget);