summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2016-01-04 19:43:00 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2016-01-04 21:26:55 +0000
commit4829edfa4ec4829c25246c46d3fcf236e6e59657 (patch)
treecb8de9718a9b409718f6a0ab95eee71a61fcaa88
parent55f0343a99ffd920e2e14ba2bb7669d78224fe42 (diff)
QTreeView: take into account the min/max size of the header view
Mimicking what QTableView is already doing correctly, the header's height needs to be constrained by its own minimum/maximum height. Task-number: QTBUG-49277 Change-Id: I695a4398991b738c4b4c924716176b9ad2152e87 Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: David Faure <david.faure@kdab.com>
-rw-r--r--src/widgets/itemviews/qtreeview.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 57092a7cdc..0ccb989198 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -2830,10 +2830,14 @@ void QTreeView::updateGeometries()
if (d->geometryRecursionBlock)
return;
d->geometryRecursionBlock = true;
- QSize hint = d->header->isHidden() ? QSize(0, 0) : d->header->sizeHint();
- setViewportMargins(0, hint.height(), 0, 0);
+ int height = 0;
+ if (!d->header->isHidden()) {
+ height = qMax(d->header->minimumHeight(), d->header->sizeHint().height());
+ height = qMin(height, d->header->maximumHeight());
+ }
+ setViewportMargins(0, height, 0, 0);
QRect vg = d->viewport->geometry();
- QRect geometryRect(vg.left(), vg.top() - hint.height(), vg.width(), hint.height());
+ QRect geometryRect(vg.left(), vg.top() - height, vg.width(), height);
d->header->setGeometry(geometryRect);
QMetaObject::invokeMethod(d->header, "updateGeometries");
d->updateScrollBars();