QtBase  v6.3.1
main.cpp
Go to the documentation of this file.
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 test suite module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
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 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #include <QApplication>
30 #include <QPushButton>
31 #include <QPlainTextEdit>
32 #include <QCalendarWidget>
33 #include <QVBoxLayout>
34 
35 class Widget : public QWidget
36 {
37  Q_OBJECT
38 public:
40  {
41  QWidget *stackWidget = new QWidget;
42  stackWidget->setFixedSize(400, 300);
43  button = new QPushButton("pushbutton", stackWidget);
44  plainTextEdit = new QPlainTextEdit(stackWidget);
45  plainTextEdit->setWordWrapMode(QTextOption::NoWrap);
46  QString s = "foo bar bar foo foo bar bar foo";
47  for (int i = 0; i < 10; ++i) {
48  plainTextEdit->appendPlainText(s);
49  s.remove(1, 2);
50  }
51  calendar = new QCalendarWidget(stackWidget);
52  button->move(10, 10);
53  button->resize(100, 100);
54  plainTextEdit->move(30, 70);
55  plainTextEdit->resize(100, 100);
56  calendar->move(80, 40);
57 
58  QWidget *buttonOps = new QWidget;
59  QVBoxLayout *l = new QVBoxLayout(buttonOps);
60  QPushButton *lower = new QPushButton("button: lower");
61  connect(lower, SIGNAL(clicked()), button, SLOT(lower()));
62  l->addWidget(lower);
63  QPushButton *raise = new QPushButton("button: raise");
64  connect(raise, SIGNAL(clicked()), button, SLOT(raise()));
65  l->addWidget(raise);
66 
67  lower = new QPushButton("calendar: lower");
68  connect(lower, SIGNAL(clicked()), calendar, SLOT(lower()));
69  l->addWidget(lower);
70  raise = new QPushButton("calendar: raise");
71  connect(raise, SIGNAL(clicked()), calendar, SLOT(raise()));
72  l->addWidget(raise);
73  QPushButton *stackUnder = new QPushButton("calendar: stack under textedit");
74  connect(stackUnder, SIGNAL(clicked()), this, SLOT(stackCalendarUnderTextEdit()));
75  l->addWidget(stackUnder);
76 
77  lower = new QPushButton("lower textedit");
78  connect(lower, SIGNAL(clicked()), plainTextEdit, SLOT(lower()));
79  l->addWidget(lower);
80  raise = new QPushButton("raise textedit");
81  connect(raise, SIGNAL(clicked()), plainTextEdit, SLOT(raise()));
82  l->addWidget(raise);
83 
84  QHBoxLayout *mainLayout = new QHBoxLayout(this);
85  mainLayout->addWidget(buttonOps);
86  mainLayout->addWidget(stackWidget);
87  }
88 
89 private Q_SLOTS:
90  void stackCalendarUnderTextEdit()
91  {
92  calendar->stackUnder(plainTextEdit);
93  }
94 
95 private:
96  QPushButton *button;
97  QPlainTextEdit *plainTextEdit;
98  QCalendarWidget *calendar;
99 };
100 
101 int main(int argc, char **argv)
102 {
103  QApplication app(argc, argv);
104  Widget w;
105  w.show();
106  return app.exec();
107 }
108 
109 #include "main.moc"
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
The QApplication class manages the GUI application's control flow and main settings.
Definition: qapplication.h:68
static int exec()
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
The QCalendarWidget class provides a monthly based calendar widget allowing the user to select a date...
friend class QWidget
The QHBoxLayout class lines up widgets horizontally.
Definition: qboxlayout.h:114
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Definition: qobject.cpp:2772
The QPlainTextEdit class provides a widget that is used to edit and display plain text.
void appendPlainText(const QString &text)
void setWordWrapMode(QTextOption::WrapMode policy)
The QPushButton widget provides a command button.
Definition: qpushbutton.h:56
The QString class provides a Unicode character string.
Definition: qstring.h:388
The QVBoxLayout class lines up widgets vertically.
Definition: qboxlayout.h:127
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:133
void move(int x, int y)
Definition: qwidget.h:913
void stackUnder(QWidget *)
Definition: qwidget.cpp:11808
void lower()
Definition: qwidget.cpp:11761
void resize(int w, int h)
Definition: qwidget.h:916
void setFixedSize(const QSize &)
Definition: widget.h:60
Widget()
Definition: main.cpp:39
int main(int argc, char **argv)
Definition: main.cpp:1
QPushButton
[1]
#define SLOT(a)
Definition: qobjectdefs.h:87
#define SIGNAL(a)
Definition: qobjectdefs.h:88
GLfloat GLfloat GLfloat w
[0]
GLdouble s
[6]
Definition: qopenglext.h:235
#define Q_OBJECT
Definition: qtmetamacros.h:158
#define Q_SLOTS
Definition: qtmetamacros.h:80
QApplication app(argc, argv)
[0]