From aa863c61ec5e68ff73c02e25a2954cdba9c2ef15 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 3 Jul 2009 16:40:32 +0200 Subject: QHeaderView: fixed the sizeHint with hidden sections We used to check the 100 first sections and 100 last sections Now we make sure we check 100 visible sections Task-number: 255574 --- src/gui/itemviews/qheaderview.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index c5e6fed30f..b1306cc259 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -526,20 +526,24 @@ QSize QHeaderView::sizeHint() const return d->cachedSizeHint; int width = 0; int height = 0; + d->executePostedLayout(); + // get size hint for the first n sections - int c = qMin(count(), 100); - for (int i = 0; i < c; ++i) { + int i = 0; + for (int checked = 0; checked < 100 && i < d->sectionCount; ++i) { if (isSectionHidden(i)) continue; + checked++; QSize hint = sectionSizeFromContents(i); width = qMax(hint.width(), width); height = qMax(hint.height(), height); } // get size hint for the last n sections - c = qMax(count() - 100, c); - for (int j = count() - 1; j >= c; --j) { + i = qMax(i, d->sectionCount - 100 ); + for (int j = d->sectionCount - 1, checked = 0; j > i && checked < 100; --j) { if (isSectionHidden(j)) continue; + checked++; QSize hint = sectionSizeFromContents(j); width = qMax(hint.width(), width); height = qMax(hint.height(), height); -- cgit v1.2.3