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