summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qstackedwidget.cpp
diff options
context:
space:
mode:
authorDebao Zhang <dbzhang800@gmail.com>2012-03-02 15:42:35 -0800
committerQt by Nokia <qt-info@nokia.com>2012-03-05 07:54:44 +0100
commit07ae18f96e87a2db40ae014f28893f1080efa7ae (patch)
tree967b125d67a07a2a4f7ee38d0a227173a99d5ffa /src/widgets/widgets/qstackedwidget.cpp
parentfb8c95bac09910c4dfa476ab97c6206b2e94ee53 (diff)
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 <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/widgets/widgets/qstackedwidget.cpp')
-rw-r--r--src/widgets/widgets/qstackedwidget.cpp46
1 files changed, 2 insertions, 44 deletions
diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp
index 5a8a382a58..3c88090eb6 100644
--- a/src/widgets/widgets/qstackedwidget.cpp
+++ b/src/widgets/widgets/qstackedwidget.cpp
@@ -49,54 +49,12 @@
QT_BEGIN_NAMESPACE
-/**
- 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. (QLayout is subject to multiple inheritance).
- However, we can fix QStackedWidget by simply using a modified version of QStackedLayout
- that reimplements the hfw-related functions:
- */
-class QStackedLayoutHFW : public QStackedLayout
-{
-public:
- QStackedLayoutHFW(QWidget *parent = 0) : QStackedLayout(parent) {}
- bool hasHeightForWidth() const;
- int heightForWidth(int width) const;
-};
-
-bool QStackedLayoutHFW::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;
-}
-
-int QStackedLayoutHFW::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;
-}
-
-
class QStackedWidgetPrivate : public QFramePrivate
{
Q_DECLARE_PUBLIC(QStackedWidget)
public:
QStackedWidgetPrivate():layout(0){}
- QStackedLayoutHFW *layout;
+ QStackedLayout *layout;
bool blockChildAdd;
};
@@ -180,7 +138,7 @@ QStackedWidget::QStackedWidget(QWidget *parent)
: QFrame(*new QStackedWidgetPrivate, parent)
{
Q_D(QStackedWidget);
- d->layout = new QStackedLayoutHFW(this);
+ d->layout = new QStackedLayout(this);
connect(d->layout, SIGNAL(widgetRemoved(int)), this, SIGNAL(widgetRemoved(int)));
connect(d->layout, SIGNAL(currentChanged(int)), this, SIGNAL(currentChanged(int)));
}