summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews/qheaderview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/itemviews/qheaderview.cpp')
-rw-r--r--src/widgets/itemviews/qheaderview.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 837383f016..1310a060ea 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -3857,6 +3857,20 @@ bool QHeaderViewPrivate::read(QDataStream &in)
if (sectionItemsLengthTotal != lengthIn)
return false;
+ const int currentCount = (orient == Qt::Horizontal ? model->columnCount(root) : model->rowCount(root));
+ if (newSectionItems.count() < currentCount) {
+ // we have sections not in the saved state, give them default settings
+ for (int i = newSectionItems.count(); i < currentCount; ++i) {
+ visualIndicesIn.append(i);
+ logicalIndicesIn.append(i);
+ }
+ const int insertCount = currentCount - newSectionItems.count();
+ const int insertLength = defaultSectionSizeIn * insertCount;
+ lengthIn += insertLength;
+ SectionItem section(defaultSectionSizeIn, globalResizeMode);
+ newSectionItems.insert(newSectionItems.count(), insertCount, section); // append
+ }
+
orientation = static_cast<Qt::Orientation>(orient);
sortIndicatorOrder = static_cast<Qt::SortOrder>(order);
sortIndicatorSection = sortIndicatorSectionIn;