QHeaderView: Honor maximumSectionSize property during resizeSections()
Resizing a QTreeeView section with double click or resizeColumnToContents() does not respect the maximumSectionSize when the resize mode is Interactive or Fixed. Since the documentation of maximumSectionSize states that it should honor this property for those cases either the documentation or implementation is incorrect. This patch fixes the latter. Task-number: QTBUG-64036 Change-Id: Ic14c8e444d50b9c50a117efed19d0bca7ec1cf82 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>bb10
parent
0445065645
commit
b4f4c384d9
|
|
@ -3364,7 +3364,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
|
|||
// because it isn't stretch, determine its width and remove that from lengthToStretch
|
||||
int sectionSize = 0;
|
||||
if (resizeMode == QHeaderView::Interactive || resizeMode == QHeaderView::Fixed) {
|
||||
sectionSize = headerSectionSize(i);
|
||||
sectionSize = qBound(q->minimumSectionSize(), headerSectionSize(i), q->maximumSectionSize());
|
||||
} else { // resizeMode == QHeaderView::ResizeToContents
|
||||
int logicalIndex = q->logicalIndex(i);
|
||||
sectionSize = qMax(viewSectionSizeHint(logicalIndex),
|
||||
|
|
|
|||
|
|
@ -3006,6 +3006,7 @@ void tst_QHeaderView::stretchAndRestoreLastSection()
|
|||
tv.setModel(&m);
|
||||
tv.showMaximized();
|
||||
|
||||
const int minimumSectionSize = 20;
|
||||
const int defaultSectionSize = 30;
|
||||
const int someOtherSectionSize = 40;
|
||||
const int biggerSizeThanAnySection = 50;
|
||||
|
|
@ -3013,6 +3014,9 @@ void tst_QHeaderView::stretchAndRestoreLastSection()
|
|||
QVERIFY(QTest::qWaitForWindowExposed(&tv));
|
||||
|
||||
QHeaderView &header = *tv.horizontalHeader();
|
||||
// set minimum size before resizeSections() is called
|
||||
// which is done inside setStretchLastSection
|
||||
header.setMinimumSectionSize(minimumSectionSize);
|
||||
header.setDefaultSectionSize(defaultSectionSize);
|
||||
header.resizeSection(9, someOtherSectionSize);
|
||||
header.setStretchLastSection(true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue