summaryrefslogtreecommitdiffstats
path: root/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2020-11-10 20:30:49 +0200
committerAhmad Samir <a.samirh78@gmail.com>2022-10-21 00:57:24 +0200
commitd60aa6a8cf8b020c2ae8e6a8bb45311acce8cab9 (patch)
tree408efaaa372dcddf057e7d89e60730a985956e84 /src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp
parent77eef3291782c967f17d703ca6a00477f7a76b11 (diff)
Layouts docs: pass parent widget in the ctor
This is a follow up from commit 1e904ab342c1aaa; changing more documentation to pass a widget * in the ctor of a layout, rather than creating a parent-less layout then calling setLayout(). Change-Id: I4fc59c6cfa46ccd279a153acd67335a6daf22ff9 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp')
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp
index 67dc4556ae..ab20b9da2e 100644
--- a/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp
@@ -2,15 +2,16 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
//! [0]
-QFormLayout *formLayout = new QFormLayout;
+QFormLayout *formLayout = new QFormLayout(this);
formLayout->addRow(tr("&Name:"), nameLineEdit);
formLayout->addRow(tr("&Email:"), emailLineEdit);
formLayout->addRow(tr("&Age:"), ageSpinBox);
-setLayout(formLayout);
//! [0]
//! [1]
+QGridLayout *gridLayout = new QGridLayout(this);
+
nameLabel = new QLabel(tr("&Name:"));
nameLabel->setBuddy(nameLineEdit);
@@ -20,14 +21,12 @@ emailLabel->setBuddy(emailLineEdit);
ageLabel = new QLabel(tr("&Name:"));
ageLabel->setBuddy(ageSpinBox);
-QGridLayout *gridLayout = new QGridLayout;
gridLayout->addWidget(nameLabel, 0, 0);
gridLayout->addWidget(nameLineEdit, 0, 1);
gridLayout->addWidget(emailLabel, 1, 0);
gridLayout->addWidget(emailLineEdit, 1, 1);
gridLayout->addWidget(ageLabel, 2, 0);
gridLayout->addWidget(ageSpinBox, 2, 1);
-setLayout(gridLayout);
//! [1]