diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-02-19 08:14:31 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-02-19 23:22:06 +0000 |
commit | f9d13af6d1961cc2e0075918a3015e68df24be43 (patch) | |
tree | 667b9e50104c025082ef146c843d6c5d22582dd7 /src/widgets/itemviews | |
parent | 78d71d156bd492bcbc1f2b97b631043bcaaf0279 (diff) |
Unbreak binary compatibility in QStyleOptionHeader
4d943846128118e1b9932a17ce6f977a0f4127a5 introduced a new data member to
QStyleOptionHeader, and reduced the size of the orientation member.
This changed the binary layout of class instances, and breaks ABI.
180c662b0790c6eceffdcb4661681d7df1541a2d added another member within
the new bitfield.
Introduce a new QStyleOptionHeaderV2 class instead with the new members,
and use that in QHeaderView, and the styles using the new members.
Fixes: QTBUG-91224
Change-Id: I47e6841e6652e4b67f247b7b4514e90be5609156
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 4c6579eacded086ad014b0fd2432095362c1d131)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r-- | src/widgets/itemviews/qheaderview.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index e815ff53fa..35f40355f5 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -2910,6 +2910,7 @@ void QHeaderView::initStyleOptionForIndex(QStyleOptionHeader *option, int logica if (!option) return; QStyleOptionHeader &opt = *option; + QStyleOptionHeaderV2 *optV2 = qstyleoption_cast<QStyleOptionHeaderV2*>(option); QStyle::State state = QStyle::State_None; if (window()->isActiveWindow()) @@ -2953,7 +2954,8 @@ void QHeaderView::initStyleOptionForIndex(QStyleOptionHeader *option, int logica Qt::FontRole); if (var.isValid() && var.canConvert<QFont>()) opt.fontMetrics = QFontMetrics(qvariant_cast<QFont>(var)); - opt.textElideMode = d->textElideMode; + if (optV2) + optV2->textElideMode = d->textElideMode; QVariant foregroundBrush = d->model->headerData(logicalIndex, d->orientation, Qt::ForegroundRole); @@ -2992,7 +2994,8 @@ void QHeaderView::initStyleOptionForIndex(QStyleOptionHeader *option, int logica opt.selectedPosition = QStyleOptionHeader::NextIsSelected; else opt.selectedPosition = QStyleOptionHeader::NotAdjacent; - opt.isSectionDragTarget = d->target == logicalIndex; + if (optV2) + optV2->isSectionDragTarget = d->target == logicalIndex; } /*! @@ -3007,7 +3010,7 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical if (!rect.isValid()) return; - QStyleOptionHeader opt; + QStyleOptionHeaderV2 opt; QPointF oldBO = painter->brushOrigin(); initStyleOption(&opt); @@ -3052,7 +3055,7 @@ QSize QHeaderView::sectionSizeFromContents(int logicalIndex) const return qvariant_cast<QSize>(variant); // otherwise use the contents - QStyleOptionHeader opt; + QStyleOptionHeaderV2 opt; initStyleOption(&opt); opt.section = logicalIndex; QVariant var = d->model->headerData(logicalIndex, d->orientation, |