diff options
Diffstat (limited to 'src/widgets/itemviews/qheaderview.cpp')
-rw-r--r-- | src/widgets/itemviews/qheaderview.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 5edf7e0547..91331b84be 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -2117,6 +2117,30 @@ void QHeaderViewPrivate::_q_layoutChanged() return; } + bool hasPersistantIndexes = false; + for (const auto &item : oldPersistentSections) { + if (item.index.isValid()) { + hasPersistantIndexes = true; + break; + } + } + + // Though far from perfect we here try to retain earlier/existing behavior + // ### See QHeaderViewPrivate::_q_layoutAboutToBeChanged() + // When we don't have valid hasPersistantIndexes it can be due to + // - all sections are default sections + // - the row/column 0 which is used for persistent indexes is gone + // - all non-default sections were removed + // case one is trivial, in case two we assume nothing else changed (it's the best + // guess we can do - everything else can not be handled correctly for now) + // case three can not be handled correctly with layoutChanged - removeSections + // should be used instead for this + if (!hasPersistantIndexes) { + if (oldCount != newCount) + q->initializeSections(); + return; + } + // adjust section size if (newCount != oldCount) { const int min = qBound(0, oldCount, newCount - 1); |