summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qstackedlayout.cpp32
-rw-r--r--src/widgets/kernel/qstackedlayout.h2
-rw-r--r--src/widgets/widgets/qstackedwidget.cpp46
3 files changed, 36 insertions, 44 deletions
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
@@ -477,6 +477,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);
diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp
index 9617d6de58..5406f5dcf5 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)));
}