1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the documentation of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** BSD License Usage
18 ** Alternatively, you may use this file under the terms of the BSD license
19 ** as follows:
20 **
21 ** "Redistribution and use in source and binary forms, with or without
22 ** modification, are permitted provided that the following conditions are
23 ** met:
24 ** * Redistributions of source code must retain the above copyright
25 ** notice, this list of conditions and the following disclaimer.
26 ** * Redistributions in binary form must reproduce the above copyright
27 ** notice, this list of conditions and the following disclaimer in
28 ** the documentation and/or other materials provided with the
29 ** distribution.
30 ** * Neither the name of The Qt Company Ltd nor the names of its
31 ** contributors may be used to endorse or promote products derived
32 ** from this software without specific prior written permission.
33 **
34 **
35 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
46 **
47 ** $QT_END_LICENSE$
48 **
49 ****************************************************************************/
50
51 #include <QtGui>
52
main(int argc,char * argv[])53 int main(int argc, char *argv[])
54 {
55 QApplication app(argc, argv);
56
57 {
58 //! [0]
59 QWidget *window = new QWidget;
60 //! [0] //! [1]
61 QPushButton *button1 = new QPushButton("One");
62 //! [1] //! [2]
63 QPushButton *button2 = new QPushButton("Two");
64 QPushButton *button3 = new QPushButton("Three");
65 QPushButton *button4 = new QPushButton("Four");
66 QPushButton *button5 = new QPushButton("Five");
67 //! [2]
68
69 //! [3]
70 QHBoxLayout *layout = new QHBoxLayout(window);
71 //! [3] //! [4]
72 layout->addWidget(button1);
73 layout->addWidget(button2);
74 layout->addWidget(button3);
75 layout->addWidget(button4);
76 layout->addWidget(button5);
77
78 //! [4]
79 window->setWindowTitle("QHBoxLayout");
80 //! [5]
81 window->show();
82 //! [5]
83 }
84
85 {
86 //! [6]
87 QWidget *window = new QWidget;
88 //! [6] //! [7]
89 QPushButton *button1 = new QPushButton("One");
90 //! [7] //! [8]
91 QPushButton *button2 = new QPushButton("Two");
92 QPushButton *button3 = new QPushButton("Three");
93 QPushButton *button4 = new QPushButton("Four");
94 QPushButton *button5 = new QPushButton("Five");
95 //! [8]
96
97 //! [9]
98 QVBoxLayout *layout = new QVBoxLayout(window);
99 //! [9] //! [10]
100 layout->addWidget(button1);
101 layout->addWidget(button2);
102 layout->addWidget(button3);
103 layout->addWidget(button4);
104 layout->addWidget(button5);
105
106 //! [10]
107 window->setWindowTitle("QVBoxLayout");
108 //! [11]
109 window->show();
110 //! [11]
111 }
112
113 {
114 //! [12]
115 QWidget *window = new QWidget;
116 //! [12] //! [13]
117 QPushButton *button1 = new QPushButton("One");
118 //! [13] //! [14]
119 QPushButton *button2 = new QPushButton("Two");
120 QPushButton *button3 = new QPushButton("Three");
121 QPushButton *button4 = new QPushButton("Four");
122 QPushButton *button5 = new QPushButton("Five");
123 //! [14]
124
125 //! [15]
126 QGridLayout *layout = new QGridLayout(window);
127 //! [15] //! [16]
128 layout->addWidget(button1, 0, 0);
129 layout->addWidget(button2, 0, 1);
130 layout->addWidget(button3, 1, 0, 1, 2);
131 layout->addWidget(button4, 2, 0);
132 layout->addWidget(button5, 2, 1);
133
134 //! [16]
135 window->setWindowTitle("QGridLayout");
136 //! [17]
137 window->show();
138 //! [17]
139 }
140
141 {
142 //! [18]
143 QWidget *window = new QWidget;
144 //! [18]
145 //! [19]
146 QPushButton *button1 = new QPushButton("One");
147 QLineEdit *lineEdit1 = new QLineEdit();
148 //! [19]
149 //! [20]
150 QPushButton *button2 = new QPushButton("Two");
151 QLineEdit *lineEdit2 = new QLineEdit();
152 QPushButton *button3 = new QPushButton("Three");
153 QLineEdit *lineEdit3 = new QLineEdit();
154 //! [20]
155 //! [21]
156 QFormLayout *layout = new QFormLayout(window);
157 //! [21]
158 //! [22]
159 layout->addRow(button1, lineEdit1);
160 layout->addRow(button2, lineEdit2);
161 layout->addRow(button3, lineEdit3);
162
163 //! [22]
164 window->setWindowTitle("QFormLayout");
165 //! [23]
166 window->show();
167 //! [23]
168 }
169
170 {
171 //! [24]
172 QVBoxLayout *layout = new QVBoxLayout;
173 layout->addWidget(formWidget);
174 setLayout(layout);
175 //! [24]
176 }
177 return app.exec();
178 }
179