summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qboxlayout.cpp54
-rw-r--r--src/widgets/kernel/qformlayout.cpp4
-rw-r--r--src/widgets/kernel/qgridlayout.cpp6
3 files changed, 49 insertions, 15 deletions
diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp
index b01227b8d5..5eaed16694 100644
--- a/src/widgets/kernel/qboxlayout.cpp
+++ b/src/widgets/kernel/qboxlayout.cpp
@@ -547,7 +547,11 @@ QLayoutItem* QBoxLayoutPrivate::replaceAt(int index, QLayoutItem *item)
Constructs a new QBoxLayout with direction \a dir and parent widget \a
parent.
- \sa direction()
+ 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().
+
+ \sa direction(), QWidget::setLayout()
*/
QBoxLayout::QBoxLayout(Direction dir, QWidget *parent)
: QLayout(*new QBoxLayoutPrivate, nullptr, parent)
@@ -1231,11 +1235,16 @@ QBoxLayout::Direction QBoxLayout::direction() const
\snippet layouts/layouts.cpp 4
\snippet layouts/layouts.cpp 5
- First, we create the widgets we want in the layout. Then, we
- create the QHBoxLayout object and add the widgets into the
- layout. Finally, we call QWidget::setLayout() to install the
- QHBoxLayout object onto the widget. At that point, the widgets in
- the layout are reparented to have \c window as their parent.
+ First, we create the widgets we want to add to the layout. Then,
+ we create the QHBoxLayout object, setting \c window as parent by
+ passing it in the constructor; next we add the widgets to the
+ layout. \c window will be the parent of the widgets that are
+ added to the layout.
+
+ If you don't pass parent \c window in the constrcutor, you can
+ at a later point use QWidget::setLayout() to install the QHBoxLayout
+ object onto \c window. At that point, the widgets in the layout are
+ reparented to have \c window as their parent.
\image qhboxlayout-with-5-children.png Horizontal box layout with five child widgets
@@ -1244,8 +1253,13 @@ QBoxLayout::Direction QBoxLayout::direction() const
/*!
- Constructs a new top-level horizontal box with
- parent \a parent.
+ Constructs a new top-level horizontal box with parent \a parent.
+
+ 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().
+
+ \sa QWidget::setLayout()
*/
QHBoxLayout::QHBoxLayout(QWidget *parent)
: QBoxLayout(LeftToRight, parent)
@@ -1294,11 +1308,16 @@ QHBoxLayout::~QHBoxLayout()
\snippet layouts/layouts.cpp 10
\snippet layouts/layouts.cpp 11
- First, we create the widgets we want in the layout. Then, we
- create the QVBoxLayout object and add the widgets into the
- layout. Finally, we call QWidget::setLayout() to install the
- QVBoxLayout object onto the widget. At that point, the widgets in
- the layout are reparented to have \c window as their parent.
+ First, we create the widgets we want to add to the layout. Then,
+ we create the QVBoxLayout object, setting \c window as parent by
+ passing it in the constructor; next we add the widgets to the
+ layout. \c window will be the parent of the widgets that are
+ added to the layout.
+
+ If you don't pass parent \c window in the constrcutor, you can
+ at a later point use QWidget::setLayout() to install the QVBoxLayout
+ object onto \c window. At that point, the widgets in the layout are
+ reparented to have \c window as their parent.
\image qvboxlayout-with-5-children.png Horizontal box layout with five child widgets
@@ -1306,8 +1325,13 @@ QHBoxLayout::~QHBoxLayout()
*/
/*!
- Constructs a new top-level vertical box with
- parent \a parent.
+ Constructs a new top-level vertical box with parent \a parent.
+
+ 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().
+
+ \sa QWidget::setLayout()
*/
QVBoxLayout::QVBoxLayout(QWidget *parent)
: QBoxLayout(TopToBottom, parent)
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index ec1e5e4156..8c3d3448ca 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -1189,6 +1189,10 @@ QLayoutItem* QFormLayoutPrivate::replaceAt(int index, QLayoutItem *newitem)
/*!
Constructs a new form layout with the given \a parent widget.
+ 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().
+
\sa QWidget::setLayout()
*/
QFormLayout::QFormLayout(QWidget *parent)
diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp
index 339677378f..3a1d89573c 100644
--- a/src/widgets/kernel/qgridlayout.cpp
+++ b/src/widgets/kernel/qgridlayout.cpp
@@ -1072,6 +1072,12 @@ QRect QGridLayoutPrivate::cellRect(int row, int col) const
Constructs a new QGridLayout with parent widget, \a parent. The
layout has one row and one column initially, and will expand when
new items are inserted.
+
+ 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().
+
+ \sa QWidget::setLayout()
*/
QGridLayout::QGridLayout(QWidget *parent)
: QLayout(*new QGridLayoutPrivate, nullptr, parent)