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>
This commit is contained in:
parent
b932f798a2
commit
7763b83c4c
@ -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);
|
||||
|
@ -193,6 +193,7 @@ protected:
|
||||
QStyleOptionHeader(int version);
|
||||
};
|
||||
|
||||
// ### Qt7: merge with QStyleOptionHeader
|
||||
class Q_WIDGETS_EXPORT QStyleOptionHeaderV2 : public QStyleOptionHeader
|
||||
{
|
||||
public:
|
||||
|
@ -4101,7 +4101,12 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
|
||||
|
||||
case CE_HeaderLabel:
|
||||
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
|
||||
QStyleOptionHeader hdr(*header);
|
||||
QStyleOptionHeaderV2 hdr;
|
||||
QStyleOptionHeader &v1Copy = hdr;
|
||||
if (auto v2 = qstyleoption_cast<const QStyleOptionHeaderV2 *>(opt))
|
||||
hdr = *v2;
|
||||
else
|
||||
v1Copy = *header;
|
||||
QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
|
||||
if (hasStyleRule(w, PseudoElement_HeaderViewUpArrow)
|
||||
|| hasStyleRule(w, PseudoElement_HeaderViewDownArrow)) {
|
||||
|
Loading…
Reference in New Issue
Block a user