path: root/src/widgets/itemviews/qheaderview_p.h
diff options
authorThorbjørn Martsum <>2015-06-26 06:36:54 +0200
committerThorbjørn Lund Martsum <>2016-01-01 12:56:29 +0000
commit024a52d0d12aaceffd67d0a1423408fb1f377d11 (patch)
tree6cf3c0f597fa021ebafeee189408edb66d558824 /src/widgets/itemviews/qheaderview_p.h
parent9059931cd2103a814d247d35998d49f03e9131e5 (diff)
QHeaderView - fix broken stretchLastSection
In setStretchLastSection we restore a default section size if we no longer use stretch. That size was however not sufficient - we should restore the actual size. Furthermore we should also always stretch the last section (last visible index) - and not leave a section with a huge size and stretch another. This patch refactors stretch handling and keeps track of the last section and its size in eg. moveSection, swapSection, hideSection, showSection etc. There is an auto test showing and guarding its behavior. [ChangeLog][QtWidgets][QHeaderView] Fixed some issues (e.g QTBUG-39010) with restoring of section size after a section is no longer the last visible section (in stretchLastSection mode). Task-number: QTBUG-39010 Change-Id: Id47075b5a9dfeb250027374ecbd10eb8babbf9ef Reviewed-by: David Faure <>
Diffstat (limited to 'src/widgets/itemviews/qheaderview_p.h')
1 files changed, 6 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h
index 60542e297a..d1982d4777 100644
--- a/src/widgets/itemviews/qheaderview_p.h
+++ b/src/widgets/itemviews/qheaderview_p.h
@@ -90,6 +90,7 @@ public:
+ lastSectionLogicalIdx(-1), // Only trust when we stretch last section
@@ -99,6 +100,9 @@ public:
int lastVisibleVisualIndex() const;
+ void restoreSizeOnPrevLastSection();
+ void setNewLastSection(int visualIndexForLastSection);
+ void maybeRestorePrevLastSectionAndStretchLast();
int sectionHandleAt(int position);
void setupSectionIndicator(int section, int position);
void updateSectionIndicator(int section, int position);
@@ -281,7 +285,8 @@ public:
int defaultSectionSize;
int minimumSectionSize;
int maximumSectionSize;
- int lastSectionSize; // $$$
+ int lastSectionSize;
+ int lastSectionLogicalIdx; // Only trust if we stretch LastSection
int sectionIndicatorOffset;
Qt::Alignment defaultAlignment;
QLabel *sectionIndicator;