From 07ae18f96e87a2db40ae014f28893f1080efa7ae Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Fri, 2 Mar 2012 15:42:35 -0800 Subject: Implements QStackedLayout's hfw-related methods. QStackedLayout does not support height for width (simply because it does not reimplement heightForWidth() and hasHeightForWidth()). That is not possible to fix without breaking binary compatibility under Qt4, which use a modified version of QStackedLayout that reimplements the hfw-related functions as a workaround. Change-Id: I81c795f0c247a2e708292de35f0650384248c6cd Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qstackedlayout.cpp | 32 ++++++++++++++++++++++++++++++++ src/widgets/kernel/qstackedlayout.h | 2 ++ 2 files changed, 34 insertions(+) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp index 9b40063e65..0d2e7716e5 100644 --- a/src/widgets/kernel/qstackedlayout.cpp +++ b/src/widgets/kernel/qstackedlayout.cpp @@ -476,6 +476,38 @@ void QStackedLayout::setGeometry(const QRect &rect) } } +/*! + \reimp +*/ +bool QStackedLayout::hasHeightForWidth() const +{ + const int n = count(); + + for (int i = 0; i < n; ++i) { + if (QLayoutItem *item = itemAt(i)) { + if (item->hasHeightForWidth()) + return true; + } + } + return false; +} + +/*! + \reimp +*/ +int QStackedLayout::heightForWidth(int width) const +{ + const int n = count(); + + int hfw = 0; + for (int i = 0; i < n; ++i) { + if (QLayoutItem *item = itemAt(i)) { + hfw = qMax(hfw, item->heightForWidth(width)); + } + } + return hfw; +} + /*! \enum QStackedLayout::StackingMode \since 4.4 diff --git a/src/widgets/kernel/qstackedlayout.h b/src/widgets/kernel/qstackedlayout.h index e54efa886e..fa77341c52 100644 --- a/src/widgets/kernel/qstackedlayout.h +++ b/src/widgets/kernel/qstackedlayout.h @@ -94,6 +94,8 @@ public: QLayoutItem *itemAt(int) const; QLayoutItem *takeAt(int); void setGeometry(const QRect &rect); + bool hasHeightForWidth() const; + int heightForWidth(int width) const; Q_SIGNALS: void widgetRemoved(int index); -- cgit v1.2.3