From 0bcfa3d5d9d67912e1d7d62e6d15acedb98cabd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Martsum?= Date: Mon, 26 Aug 2013 12:14:03 +0200 Subject: QHeaderView - add maximum section size When we auto resize it is handy to be able to limit the maximum size (just like the minimum size). [ChangeLog][QtWidgets][QHeaderView]A maximumSize for sections has been introduced. The maximum section size is by default the largest possible section size which in Qt 5.2 has been limited to 1048575 pixels. Task-number: QTBUG-4346 Change-Id: Ida9cbcc11bd5c4498e319df2e6379c69a7033c04 Reviewed-by: Stephen Kelly --- .../auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/auto/widgets/itemviews/qheaderview') diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 09f0161dff..398b1b4d98 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -2721,6 +2721,20 @@ void tst_QHeaderView::resizeToContentTest() QVERIFY(view->sectionSize(1) > 1); QVERIFY(view->sectionSize(2) > 1); + // Check minimum section size + hh->setMinimumSectionSize(150); + model->setData(idx, QVariant("i")); + hh->resizeSections(QHeaderView::ResizeToContents); + QCOMPARE(hh->sectionSize(3), 150); + hh->setMinimumSectionSize(-1); + + // Check maximumSection size + hh->setMaximumSectionSize(200); + model->setData(idx, QVariant("This is a even longer string that is expected to be more than 200 pixels")); + hh->resizeSections(QHeaderView::ResizeToContents); + QCOMPARE(hh->sectionSize(3), 200); + hh->setMaximumSectionSize(-1); + view->setDefaultSectionSize(25); // To make sure our precalced data are correct. We do not know font height etc. const int precalced_results[] = { -1523279360, -1523279360, -1347156568, 1, 1719705216, 1719705216, 12500 }; -- cgit v1.2.3