From d60aa6a8cf8b020c2ae8e6a8bb45311acce8cab9 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 10 Nov 2020 20:30:49 +0200 Subject: Layouts docs: pass parent widget in the ctor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/widgets/doc/snippets/code/src_gui_kernel_qformlayout.cpp') 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] -- cgit v1.2.3