summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/itemviews/qheaderview.cpp1
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp10
2 files changed, 11 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 762e852f88..70f8b28299 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -3834,6 +3834,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize)
void QHeaderViewPrivate::setDefaultSectionSize(int size)
{
Q_Q(QHeaderView);
+ size = qBound(q->minimumSectionSize(), size, q->maximumSectionSize());
executePostedLayout();
invalidateCachedSizeHint();
defaultSectionSize = size;
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 05eef7c091..b6932d4892 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -405,6 +405,7 @@ void tst_QHeaderView::getSetCheck()
// int QHeaderView::defaultSectionSize()
// void QHeaderView::setDefaultSectionSize(int)
+ obj1.setMinimumSectionSize(0);
obj1.setDefaultSectionSize(-1);
QVERIFY(obj1.defaultSectionSize() >= 0);
obj1.setDefaultSectionSize(0);
@@ -2060,6 +2061,7 @@ void tst_QHeaderView::defaultSectionSize()
QHeaderView h((Qt::Orientation)direction);
h.setModel(&m);
+ h.setMinimumSectionSize(0);
QCOMPARE(h.defaultSectionSize(), oldDefaultSize);
h.setDefaultSectionSize(newDefaultSize);
@@ -3326,8 +3328,16 @@ void tst_QHeaderView::testMinMaxSectionSize()
QHeaderView &header = *tv.horizontalHeader();
header.setMinimumSectionSize(sectionSizeMin);
header.setMaximumSectionSize(sectionSizeMax);
+ // check bounds for default section size
+ header.setDefaultSectionSize(sectionSizeMin - 1);
+ QCOMPARE(header.defaultSectionSize(), sectionSizeMin);
+ header.setDefaultSectionSize(sectionSizeMax + 1);
+ QCOMPARE(header.defaultSectionSize(), sectionSizeMax);
+
header.setDefaultSectionSize(defaultSectionSize);
+ QCOMPARE(header.defaultSectionSize(), defaultSectionSize);
header.setStretchLastSection(stretchLastSection);
+ QCOMPARE(header.stretchLastSection(), stretchLastSection);
// check defaults
QCOMPARE(header.sectionSize(0), defaultSectionSize);