|
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 examples 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 "mainwindow.h" |
|
43 |
|
44 #include <QApplication> |
|
45 #include <QMenuBar> |
|
46 #include <QGroupBox> |
|
47 #include <QGridLayout> |
|
48 #include <QSlider> |
|
49 #include <QLabel> |
|
50 #include <QTimer> |
|
51 |
|
52 #include "glwidget.h" |
|
53 |
|
54 MainWindow::MainWindow() |
|
55 { |
|
56 GLWidget *glwidget = new GLWidget(); |
|
57 QLabel *label = new QLabel(this); |
|
58 QTimer *timer = new QTimer(this); |
|
59 QSlider *slider = new QSlider(this); |
|
60 slider->setOrientation(Qt::Horizontal); |
|
61 |
|
62 slider->setRange(0, 100); |
|
63 slider->setSliderPosition(50); |
|
64 timer->setInterval(10); |
|
65 label->setText("A QGlWidget with OpenGl ES"); |
|
66 label->setAlignment(Qt::AlignHCenter); |
|
67 |
|
68 QGroupBox * groupBox = new QGroupBox(this); |
|
69 setCentralWidget(groupBox); |
|
70 groupBox->setTitle("OpenGL ES Example"); |
|
71 |
|
72 QGridLayout *layout = new QGridLayout(groupBox); |
|
73 |
|
74 layout->addWidget(glwidget,1,0,8,1); |
|
75 layout->addWidget(label,9,0,1,1); |
|
76 layout->addWidget(slider, 11,0,1,1); |
|
77 |
|
78 groupBox->setLayout(layout); |
|
79 |
|
80 QMenu *fileMenu = new QMenu("File"); |
|
81 QMenu *helpMenu = new QMenu("Help"); |
|
82 QMenu *showMenu = new QMenu("Show"); |
|
83 menuBar()->addMenu(fileMenu); |
|
84 menuBar()->addMenu(showMenu); |
|
85 menuBar()->addMenu(helpMenu); |
|
86 QAction *exit = new QAction("Exit", fileMenu); |
|
87 QAction *aboutQt = new QAction("AboutQt", helpMenu); |
|
88 QAction *showLogo = new QAction("Show 3D Logo", showMenu); |
|
89 QAction *showTexture = new QAction("Show 2D Texture", showMenu); |
|
90 QAction *showBubbles = new QAction("Show bubbles", showMenu); |
|
91 showBubbles->setCheckable(true); |
|
92 showBubbles->setChecked(true); |
|
93 fileMenu->addAction(exit); |
|
94 helpMenu->addAction(aboutQt); |
|
95 showMenu->addAction(showLogo); |
|
96 showMenu->addAction(showTexture); |
|
97 showMenu->addAction(showBubbles); |
|
98 |
|
99 QObject::connect(timer, SIGNAL(timeout()), glwidget, SLOT(updateGL())); |
|
100 QObject::connect(exit, SIGNAL(triggered(bool)), this, SLOT(close())); |
|
101 QObject::connect(aboutQt, SIGNAL(triggered(bool)), qApp, SLOT(aboutQt())); |
|
102 |
|
103 QObject::connect(showLogo, SIGNAL(triggered(bool)), glwidget, SLOT(setLogo())); |
|
104 QObject::connect(showTexture, SIGNAL(triggered(bool)), glwidget, SLOT(setTexture())); |
|
105 QObject::connect(showBubbles, SIGNAL(triggered(bool)), glwidget, SLOT(showBubbles(bool))); |
|
106 QObject::connect(slider, SIGNAL(valueChanged(int)), glwidget, SLOT(setScaling(int))); |
|
107 timer->start(); |
|
108 } |