source: trunk/examples/activeqt/opengl/globjwin.cpp@ 1168

Last change on this file since 1168 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 4.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the examples 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 "globjwin.h"
42#include "glbox.h"
43#include <QPushButton>
44#include <QSlider>
45#include <QLayout>
46#include <QFrame>
47#include <QMenuBar>
48#include <QMenu>
49#include <QApplication>
50
51
52GLObjectWindow::GLObjectWindow(QWidget* parent)
53 : QWidget(parent)
54{
55
56 // Create a menu
57 QMenu *file = new QMenu( this );
58 file->addAction( "Exit", qApp, SLOT(quit())/*, CTRL+Key_Q*/);
59
60 // Create a menu bar
61 QMenuBar *m = new QMenuBar( this );
62 m->addMenu(file)->setText("&File");
63
64 // Create a nice frame to put around the OpenGL widget
65 QFrame* f = new QFrame(this);
66 f->setFrameStyle( QFrame::Sunken | QFrame::Panel );
67 f->setLineWidth( 2 );
68
69 // Create our OpenGL widget
70 GLBox* c = new GLBox( f, "glbox");
71
72 // Create the three sliders; one for each rotation axis
73 QSlider* x = new QSlider(Qt::Vertical, this);
74 x->setMaximum(360);
75 x->setPageStep(60);
76 x->setTickPosition( QSlider::TicksLeft );
77 QObject::connect( x, SIGNAL(valueChanged(int)),c,SLOT(setXRotation(int)) );
78
79 QSlider* y = new QSlider(Qt::Vertical, this);
80 y->setMaximum(360);
81 y->setPageStep(60);
82 y->setTickPosition( QSlider::TicksLeft );
83 QObject::connect( y, SIGNAL(valueChanged(int)),c,SLOT(setYRotation(int)) );
84
85 QSlider* z = new QSlider(Qt::Vertical, this);
86 z->setMaximum(360);
87 z->setPageStep(60);
88 z->setTickPosition( QSlider::TicksLeft );
89 QObject::connect( z, SIGNAL(valueChanged(int)),c,SLOT(setZRotation(int)) );
90
91 // Now that we have all the widgets, put them into a nice layout
92
93 // Top level layout, puts the sliders to the left of the frame/GL widget
94 QHBoxLayout* hlayout = new QHBoxLayout(this);
95
96 // Put the sliders on top of each other
97 QVBoxLayout* vlayout = new QVBoxLayout();
98 vlayout->addWidget( x );
99 vlayout->addWidget( y );
100 vlayout->addWidget( z );
101
102 // Put the GL widget inside the frame
103 QHBoxLayout* flayout = new QHBoxLayout(f);
104 flayout->setMargin(0);
105 flayout->addWidget( c, 1 );
106
107 hlayout->setMenuBar( m );
108 hlayout->addLayout( vlayout );
109 hlayout->addWidget( f, 1 );
110}
Note: See TracBrowser for help on using the repository browser.