~gabriel1984sibiu/minitube/qt5.6

« back to all changes in this revision

Viewing changes to tests/manual/qwidget_zorder/main.cpp

  • Committer: Grevutiu Gabriel
  • Date: 2017-06-13 08:43:17 UTC
  • Revision ID: gabriel1984sibiu@gmail.com-20170613084317-ek0zqe0u9g3ocvi8
OriginalĀ upstreamĀ code

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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:
 
39
    Widget()
 
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"