summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-11-01 20:29:59 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-11-02 14:25:03 +0100
commitd76b9d86e85ed7c0705209caca40b7a0efc71e14 (patch)
tree57254eb3b8f7fbb6970858dbb64e0795167e4f69 /src
parent3b8d37b1f04acf60ceb144bfa5ed82e72e59a255 (diff)
QLayout: unify the constructors
Drive-by, make QLayout constructor explicit, as it should have always been. [ChangeLog][QtWidgets][QLayout] The QLayout constructor taking a QWidget pointer is now explicit. Change-Id: If6accfb2e7e810fa08adacea9e674c99121f6bc6 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qgridlayout.cpp21
-rw-r--r--src/widgets/kernel/qgridlayout.h4
-rw-r--r--src/widgets/kernel/qlayout.cpp19
-rw-r--r--src/widgets/kernel/qlayout.h3
4 files changed, 12 insertions, 35 deletions
diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp
index 3a1d89573c..121bae0352 100644
--- a/src/widgets/kernel/qgridlayout.cpp
+++ b/src/widgets/kernel/qgridlayout.cpp
@@ -1077,6 +1077,10 @@ QRect QGridLayoutPrivate::cellRect(int row, int col) const
There can be only one top-level layout for a widget. It is returned
by QWidget::layout().
+ If \a parent is \nullptr, then you must insert this grid layout
+ into another layout, or set it as a widget's layout using
+ QWidget::setLayout().
+
\sa QWidget::setLayout()
*/
QGridLayout::QGridLayout(QWidget *parent)
@@ -1087,23 +1091,6 @@ QGridLayout::QGridLayout(QWidget *parent)
}
/*!
- Constructs a new grid layout.
-
- You must insert this grid into another layout. You can insert
- widgets and layouts into this layout at any time, but laying out
- will not be performed before this is inserted into another layout.
-*/
-QGridLayout::QGridLayout()
- : QLayout(*new QGridLayoutPrivate, nullptr, nullptr)
-{
- Q_D(QGridLayout);
- d->expand(1, 1);
-}
-
-
-
-
-/*!
\internal (mostly)
Sets the positioning mode used by addItem(). If \a orient is
diff --git a/src/widgets/kernel/qgridlayout.h b/src/widgets/kernel/qgridlayout.h
index 36c79285dd..1107d850eb 100644
--- a/src/widgets/kernel/qgridlayout.h
+++ b/src/widgets/kernel/qgridlayout.h
@@ -61,9 +61,7 @@ class Q_WIDGETS_EXPORT QGridLayout : public QLayout
QDOC_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
public:
- explicit QGridLayout(QWidget *parent);
- QGridLayout();
-
+ explicit QGridLayout(QWidget *parent = nullptr);
~QGridLayout();
QSize sizeHint() const override;
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index c62c8fae41..6dce2da969 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -106,11 +106,16 @@ static int menuBarHeightForWidth(QWidget *menubar, int w)
/*!
Constructs a new top-level QLayout, with parent \a parent.
- \a parent may not be \nullptr.
The layout is set directly as the top-level layout for
\a parent. There can be only one top-level layout for a
widget. It is returned by QWidget::layout().
+
+ If \a parent is \nullptr, then you must insert this layout
+ into another layout, or set it as a widget's layout using
+ QWidget::setLayout().
+
+ \sa QWidget::setLayout()
*/
QLayout::QLayout(QWidget *parent)
: QObject(*new QLayoutPrivate, parent)
@@ -120,18 +125,6 @@ QLayout::QLayout(QWidget *parent)
parent->setLayout(this);
}
-/*!
- Constructs a new child QLayout.
-
- This layout has to be inserted into another layout before geometry
- management will work.
-*/
-QLayout::QLayout()
- : QObject(*new QLayoutPrivate, nullptr)
-{
-}
-
-
/*! \internal
*/
QLayout::QLayout(QLayoutPrivate &dd, QLayout *lay, QWidget *w)
diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h
index 0a887e833c..0377aa62b3 100644
--- a/src/widgets/kernel/qlayout.h
+++ b/src/widgets/kernel/qlayout.h
@@ -77,8 +77,7 @@ public:
};
Q_ENUM(SizeConstraint)
- QLayout(QWidget *parent);
- QLayout();
+ explicit QLayout(QWidget *parent = nullptr);
~QLayout();
virtual int spacing() const;