1 | #include <QtGui> |
---|
2 | |
---|
3 | #include "glwidget.h" |
---|
4 | #include "window.h" |
---|
5 | |
---|
6 | Window::Window() |
---|
7 | { |
---|
8 | glWidget = new GLWidget; |
---|
9 | |
---|
10 | xSlider = createSlider(); |
---|
11 | ySlider = createSlider(); |
---|
12 | zSlider = createSlider(); |
---|
13 | |
---|
14 | connect(xSlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setXRotation(int))); |
---|
15 | connect(glWidget, SIGNAL(xRotationChanged(int)), xSlider, SLOT(setValue(int))); |
---|
16 | connect(ySlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setYRotation(int))); |
---|
17 | connect(glWidget, SIGNAL(yRotationChanged(int)), ySlider, SLOT(setValue(int))); |
---|
18 | connect(zSlider, SIGNAL(valueChanged(int)), glWidget, SLOT(setZRotation(int))); |
---|
19 | connect(glWidget, SIGNAL(zRotationChanged(int)), zSlider, SLOT(setValue(int))); |
---|
20 | |
---|
21 | QHBoxLayout *mainLayout = new QHBoxLayout; |
---|
22 | mainLayout->addWidget(glWidget); |
---|
23 | mainLayout->addWidget(xSlider); |
---|
24 | mainLayout->addWidget(ySlider); |
---|
25 | mainLayout->addWidget(zSlider); |
---|
26 | setLayout(mainLayout); |
---|
27 | |
---|
28 | xSlider->setValue(15 * 16); |
---|
29 | ySlider->setValue(345 * 16); |
---|
30 | zSlider->setValue(0 * 16); |
---|
31 | setWindowTitle(tr("Hello GL")); |
---|
32 | } |
---|
33 | |
---|
34 | QSlider *Window::createSlider() |
---|
35 | { |
---|
36 | QSlider *slider = new QSlider(Qt::Vertical); |
---|
37 | slider->setRange(0, 360 * 16); |
---|
38 | slider->setSingleStep(16); |
---|
39 | slider->setPageStep(15 * 16); |
---|
40 | slider->setTickInterval(15 * 16); |
---|
41 | slider->setTickPosition(QSlider::TicksRight); |
---|
42 | return slider; |
---|
43 | } |
---|