|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 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 test suite module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include <QtGui> |
|
43 |
|
44 class Widget : public QWidget |
|
45 { |
|
46 Q_OBJECT |
|
47 public: |
|
48 Widget() |
|
49 { |
|
50 QWidget *stackWidget = new QWidget; |
|
51 stackWidget->setFixedSize(400, 300); |
|
52 button = new QPushButton("pushbutton", stackWidget); |
|
53 plainTextEdit = new QPlainTextEdit(stackWidget); |
|
54 plainTextEdit->setWordWrapMode(QTextOption::NoWrap); |
|
55 QString s = "foo bar bar foo foo bar bar foo"; |
|
56 for (int i = 0; i < 10; ++i) { |
|
57 plainTextEdit->appendPlainText(s); |
|
58 s.remove(1, 2); |
|
59 } |
|
60 calendar = new QCalendarWidget(stackWidget); |
|
61 button->move(10, 10); |
|
62 button->resize(100, 100); |
|
63 plainTextEdit->move(30, 70); |
|
64 plainTextEdit->resize(100, 100); |
|
65 calendar->move(80, 40); |
|
66 |
|
67 QWidget *buttonOps = new QWidget; |
|
68 QVBoxLayout *l = new QVBoxLayout(buttonOps); |
|
69 QPushButton *lower = new QPushButton("button: lower"); |
|
70 connect(lower, SIGNAL(clicked()), button, SLOT(lower())); |
|
71 l->addWidget(lower); |
|
72 QPushButton *raise = new QPushButton("button: raise"); |
|
73 connect(raise, SIGNAL(clicked()), button, SLOT(raise())); |
|
74 l->addWidget(raise); |
|
75 |
|
76 lower = new QPushButton("calendar: lower"); |
|
77 connect(lower, SIGNAL(clicked()), calendar, SLOT(lower())); |
|
78 l->addWidget(lower); |
|
79 raise = new QPushButton("calendar: raise"); |
|
80 connect(raise, SIGNAL(clicked()), calendar, SLOT(raise())); |
|
81 l->addWidget(raise); |
|
82 QPushButton *stackUnder = new QPushButton("calendar: stack under textedit"); |
|
83 connect(stackUnder, SIGNAL(clicked()), this, SLOT(stackCalendarUnderTextEdit())); |
|
84 l->addWidget(stackUnder); |
|
85 |
|
86 lower = new QPushButton("lower textedit"); |
|
87 connect(lower, SIGNAL(clicked()), plainTextEdit, SLOT(lower())); |
|
88 l->addWidget(lower); |
|
89 raise = new QPushButton("raise textedit"); |
|
90 connect(raise, SIGNAL(clicked()), plainTextEdit, SLOT(raise())); |
|
91 l->addWidget(raise); |
|
92 |
|
93 QHBoxLayout *mainLayout = new QHBoxLayout(this); |
|
94 mainLayout->addWidget(buttonOps); |
|
95 mainLayout->addWidget(stackWidget); |
|
96 } |
|
97 |
|
98 private Q_SLOTS: |
|
99 void stackCalendarUnderTextEdit() |
|
100 { |
|
101 calendar->stackUnder(plainTextEdit); |
|
102 } |
|
103 |
|
104 private: |
|
105 QPushButton *button; |
|
106 QPlainTextEdit *plainTextEdit; |
|
107 QCalendarWidget *calendar; |
|
108 }; |
|
109 |
|
110 int main(int argc, char **argv) |
|
111 { |
|
112 QApplication app(argc, argv); |
|
113 Widget w; |
|
114 w.show(); |
|
115 return app.exec(); |
|
116 } |
|
117 |
|
118 #include "main.moc" |