Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
src_gui_kernel_qformlayout.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4
#
include
<
QtCore
/
qpointer
.
h
>
5
6
//! [0]
7
QFormLayout
*
formLayout
=
new
QFormLayout(
this
);
8
formLayout->addRow(tr(
"&Name:"
), nameLineEdit);
9
formLayout->addRow(tr(
"&Email:"
), emailLineEdit);
10
formLayout->addRow(tr(
"&Age:"
), ageSpinBox);
11
//! [0]
12
13
14
//! [1]
15
QGridLayout
*
gridLayout
=
new
QGridLayout(
this
);
16
17
nameLabel
=
new
QLabel(tr(
"&Name:"
));
18
nameLabel->setBuddy(nameLineEdit);
19
20
emailLabel
=
new
QLabel(tr(
"&Name:"
));
21
emailLabel->setBuddy(emailLineEdit);
22
23
ageLabel
=
new
QLabel(tr(
"&Name:"
));
24
ageLabel->setBuddy(ageSpinBox);
25
26
gridLayout->addWidget(nameLabel, 0, 0);
27
gridLayout->addWidget(nameLineEdit, 0, 1);
28
gridLayout->addWidget(emailLabel, 1, 0);
29
gridLayout->addWidget(emailLineEdit, 1, 1);
30
gridLayout->addWidget(ageLabel, 2, 0);
31
gridLayout->addWidget(ageSpinBox, 2, 1);
32
//! [1]
33
34
35
//! [2]
36
formLayout->setRowWrapPolicy(QFormLayout::DontWrapRows);
37
formLayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
38
formLayout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
39
formLayout->setLabelAlignment(Qt::AlignLeft);
40
//! [2]
41
42
//! [3]
43
QFormLayout
*
flay
= ...;
44
QPointer
<
QLineEdit
>
le
=
new
QLineEdit;
45
flay->insertRow(2,
"User:"
, le);
46
// later:
47
flay->removeRow(2);
// le == nullptr at this point
48
//! [3]
49
50
//! [4]
51
QFormLayout
*
flay
= ...;
52
QPointer
<
QLineEdit
>
le
=
new
QLineEdit;
53
flay->insertRow(2,
"User:"
, le);
54
// later:
55
flay->removeRow(le);
// le == nullptr at this point
56
//! [4]
57
58
//! [5]
59
QFormLayout
*
flay
= ...;
60
QPointer
<
QVBoxLayout
>
vbl
=
new
QVBoxLayout;
61
flay->insertRow(2,
"User:"
, vbl);
62
// later:
63
flay->removeRow(layout);
// vbl == nullptr at this point
64
//! [5]
65
66
//! [6]
67
QFormLayout
*
flay
= ...;
68
QPointer
<
QLineEdit
>
le
=
new
QLineEdit;
69
flay->insertRow(2,
"User:"
, le);
70
// later:
71
QFormLayout
::
TakeRowResult
result
= flay->takeRow(2);
72
//! [6]
73
74
//! [7]
75
QFormLayout
*
flay
= ...;
76
QPointer
<
QLineEdit
>
le
=
new
QLineEdit;
77
flay->insertRow(2,
"User:"
, le);
78
// later:
79
QFormLayout
::
TakeRowResult
result
= flay->takeRow(widget);
80
//! [7]
81
82
//! [8]
83
QFormLayout
*
flay
= ...;
84
QPointer
<
QVBoxLayout
>
vbl
=
new
QVBoxLayout;
85
flay->insertRow(2,
"User:"
, vbl);
86
// later:
87
QFormLayout
::
TakeRowResult
result
= flay->takeRow(widget);
88
//! [8]
result
auto result
[6]
Definition
src_concurrent_qtconcurrenttask.cpp:24
ageLabel
ageLabel
Definition
src_gui_kernel_qformlayout.cpp:23
formLayout
QFormLayout * formLayout
[0]
Definition
src_gui_kernel_qformlayout.cpp:7
nameLabel
nameLabel
Definition
src_gui_kernel_qformlayout.cpp:17
vbl
QPointer< QVBoxLayout > vbl
Definition
src_gui_kernel_qformlayout.cpp:60
emailLabel
emailLabel
Definition
src_gui_kernel_qformlayout.cpp:20
gridLayout
QGridLayout * gridLayout
[0]
Definition
src_gui_kernel_qformlayout.cpp:15
flay
QFormLayout * flay
[2]
Definition
src_gui_kernel_qformlayout.cpp:43
le
QPointer< QLineEdit > le
Definition
src_gui_kernel_qformlayout.cpp:44
qtbase
src
widgets
doc
snippets
code
src_gui_kernel_qformlayout.cpp
Generated on
for Qt by
1.18.0