summaryrefslogtreecommitdiffstats
path: root/src/widgets/doc/snippets
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2020-10-26 18:08:57 +0200
committerAhmad Samir <a.samirh78@gmail.com>2020-10-27 13:49:39 +0200
commit1e904ab342c1aaabbef67cbcc25cf3de9e35e755 (patch)
tree32da202a93007aa353352b3e9c376ed5ad75ea42 /src/widgets/doc/snippets
parent07ab7c11b5d6a7c81dec96641d92ae1af3c33e16 (diff)
QLayout docs: explain better what the QWidget ctor arg does
Make it clear in the docs that an alternative to calling QWidget::setLayout() is to pass the parent widget to the Q*BoxLayout constructor. This basically just copies the relevant bits from the the docs of QWidget and Q*Layout. Change-Id: Id196dcdf9a876d9141aa145f23a83c45f8cda5f8 Pick-to: 5.15 5.12 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/doc/snippets')
-rw-r--r--src/widgets/doc/snippets/layouts/layouts.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/widgets/doc/snippets/layouts/layouts.cpp b/src/widgets/doc/snippets/layouts/layouts.cpp
index 6d2ea580b4..4b15cc6d1a 100644
--- a/src/widgets/doc/snippets/layouts/layouts.cpp
+++ b/src/widgets/doc/snippets/layouts/layouts.cpp
@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
//! [2]
//! [3]
- QHBoxLayout *layout = new QHBoxLayout;
+ QHBoxLayout *layout = new QHBoxLayout(window);
//! [3] //! [4]
layout->addWidget(button1);
layout->addWidget(button2);
@@ -75,7 +75,6 @@ int main(int argc, char *argv[])
layout->addWidget(button4);
layout->addWidget(button5);
- window->setLayout(layout);
//! [4]
window->setWindowTitle("QHBoxLayout");
//! [5]
@@ -96,7 +95,7 @@ int main(int argc, char *argv[])
//! [8]
//! [9]
- QVBoxLayout *layout = new QVBoxLayout;
+ QVBoxLayout *layout = new QVBoxLayout(window);
//! [9] //! [10]
layout->addWidget(button1);
layout->addWidget(button2);
@@ -104,7 +103,6 @@ int main(int argc, char *argv[])
layout->addWidget(button4);
layout->addWidget(button5);
- window->setLayout(layout);
//! [10]
window->setWindowTitle("QVBoxLayout");
//! [11]
@@ -125,7 +123,7 @@ int main(int argc, char *argv[])
//! [14]
//! [15]
- QGridLayout *layout = new QGridLayout;
+ QGridLayout *layout = new QGridLayout(window);
//! [15] //! [16]
layout->addWidget(button1, 0, 0);
layout->addWidget(button2, 0, 1);
@@ -133,7 +131,6 @@ int main(int argc, char *argv[])
layout->addWidget(button4, 2, 0);
layout->addWidget(button5, 2, 1);
- window->setLayout(layout);
//! [16]
window->setWindowTitle("QGridLayout");
//! [17]
@@ -156,14 +153,13 @@ int main(int argc, char *argv[])
QLineEdit *lineEdit3 = new QLineEdit();
//! [20]
//! [21]
- QFormLayout *layout = new QFormLayout;
+ QFormLayout *layout = new QFormLayout(window);
//! [21]
//! [22]
layout->addRow(button1, lineEdit1);
layout->addRow(button2, lineEdit2);
layout->addRow(button3, lineEdit3);
- window->setLayout(layout);
//! [22]
window->setWindowTitle("QFormLayout");
//! [23]