summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2012-10-28 05:23:08 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-31 00:03:22 (GMT)
commit4ccc7ff70918f1fdbe37637aa72e02d5a90a6550 (patch)
tree0d633281c5f42b6e1f7f965fbf73ca8788ae8f6c
parent46d033ea478d472c9dda8b0b8a0890299d6cd823 (diff)
downloadQt-4ccc7ff70918f1fdbe37637aa72e02d5a90a6550.zip
Qt-4ccc7ff70918f1fdbe37637aa72e02d5a90a6550.tar.gz
Qt-4ccc7ff70918f1fdbe37637aa72e02d5a90a6550.tar.bz2
QHeaderView - length returns wrong value fix
setSectionHidden called with (logindex, true) will sometimes not do a (correct) call to resizeSection(logicalIndex, 0) at once. However it does execute d->doDelayedResizeSections(). Therefore the section is going to be hidden later. However it is a problem that the length meanwhile is wrong. (That is a value that is not the sum of the sections) This is fixed by execute updates before returning the length. This is a backport of SHA 125016ad241125176e5bebab94eebcf50fac20bc Task-number: QTBUG-14242 Change-Id: Ia1d2f6db3213792b250a6a37942b56554261cd3a Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
-rw-r--r--src/gui/itemviews/qheaderview.cpp2
-rw-r--r--tests/auto/qheaderview/tst_qheaderview.cpp18
2 files changed, 20 insertions, 0 deletions
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index 3c9ff8b..4fa155a 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -509,6 +509,8 @@ void QHeaderView::setOffsetToLastSection()
int QHeaderView::length() const
{
Q_D(const QHeaderView);
+ d->executePostedLayout();
+ d->executePostedResize();
//Q_ASSERT(d->headerLength() == d->length);
return d->length;
}
diff --git a/tests/auto/qheaderview/tst_qheaderview.cpp b/tests/auto/qheaderview/tst_qheaderview.cpp
index 1d41069..6e68564 100644
--- a/tests/auto/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/qheaderview/tst_qheaderview.cpp
@@ -194,6 +194,7 @@ private slots:
void QTBUG7833_sectionClicked();
void QTBUG8650_crashOnInsertSections();
void QTBUG12268_hiddenMovedSectionSorting();
+ void QTBUG14242_hideSectionAutoSize();
void initialSortOrderRole();
@@ -2109,6 +2110,23 @@ void tst_QHeaderView::QTBUG12268_hiddenMovedSectionSorting()
QCOMPARE(view.horizontalHeader()->hiddenSectionCount(), 1);
}
+void tst_QHeaderView::QTBUG14242_hideSectionAutoSize()
+{
+ QTableView qtv;
+ QStandardItemModel amodel(4, 4);
+ qtv.setModel(&amodel);
+ QHeaderView *hv = qtv.verticalHeader();
+ hv->setDefaultSectionSize(25);
+ hv->setResizeMode(QHeaderView::ResizeToContents);
+ qtv.show();
+ hv->hideSection(0);
+ int afterlength = hv->length();
+ int calced_length = 0;
+ for (int u = 0; u < hv->count(); ++u)
+ calced_length += hv->sectionSize(u);
+ QVERIFY(calced_length == afterlength);
+}
+
void tst_QHeaderView::initialSortOrderRole()
{
QTableView view;