summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2012-10-09 15:55:24 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-18 13:32:45 +0200
commit4aa9e184b527eb30c0e86576c6fc89fe63433c7e (patch)
tree4b3fb6075fe0a86ef5449e01d92cc8c524aefa73 /src
parent62e9682abecaf7e38f6dd9640a3aa964bdd21d0d (diff)
Fix a regression with regards to hfw behavior in QStackedWidget
This is a regression because we made QStackedWidget actually support heightForWidth in 4.8. This was done with change 4780f94e391b5e881497c5228661dead42c821fa. The problem was that heightForWidth was not calculated correctly because some of the pages were hidden. The hidden pages were actually not contributing to the hfw of the QStackedWidget at all. This again caused the QStackedWidget to change its heightForWidth() value when the current tab changed, which again could cause "jumps" in the UI when switching tabs (as demonstrated in the task). The problem was that the patch relied on calling QWidgetItem::heightForWidth(), and this function would return -1 if the widget was hidden. However, QWidget::heightForWidth() does not have this magic and returns the proper hfw value regardless of its visibility. One could argue about the correctness of this patch, but since QStackedLayout::sizeHint() disregards QWidgetItem::sizeHint() (it asks the widget directly), we do the same in QStackedLayoutHFW::heightForWidth() for consistency. In addition, QStackedLayout enforces that only widgets can be added to it, and you cannot add your own QLayoutItem subclasses to it: qWarning("QStackedLayout::addItem: Only widgets can be added"); Change-Id: I0196a9e8e3ef3a36ce0e1a2929dfd58edeb93c69 Task-id: QTBUG-24758 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/qstackedwidget.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/widgets/qstackedwidget.cpp b/src/gui/widgets/qstackedwidget.cpp
index f2cd245355..8a68cf2ba5 100644
--- a/src/gui/widgets/qstackedwidget.cpp
+++ b/src/gui/widgets/qstackedwidget.cpp
@@ -84,9 +84,12 @@ int QStackedLayoutHFW::heightForWidth(int width) const
int hfw = 0;
for (int i = 0; i < n; ++i) {
if (QLayoutItem *item = itemAt(i)) {
- hfw = qMax(hfw, item->heightForWidth(width));
+ if (QWidget *w = item->widget())
+ hfw = qMax(hfw, w->heightForWidth(width));
}
}
+
+ hfw = qMax(hfw, minimumSize().height());
return hfw;
}