-
Notifications
You must be signed in to change notification settings - Fork 0
/
minesfieldscrollablewidget.cpp
52 lines (40 loc) · 1.54 KB
/
minesfieldscrollablewidget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "minesfieldscrollablewidget.h"
MinesFieldScrollableWidget::MinesFieldScrollableWidget(QWidget* parent)
: QWidget(parent)
{
minesFieldWidget = new MinesFieldWidget(this);
QGridLayout* layout = new QGridLayout;
verticalScrollBar = new QScrollBar;
verticalScrollBar->setRange(-10, 10);
horizontalScrollBar = new QScrollBar;
horizontalScrollBar->setRange(-10, 10);
horizontalScrollBar->setOrientation(Qt::Horizontal);
QObject::connect(horizontalScrollBar, SIGNAL(valueChanged(int)),
minesFieldWidget, SLOT(horizontalScrollPosChanged(int)));
QObject::connect(verticalScrollBar, SIGNAL(valueChanged(int)),
minesFieldWidget, SLOT(verticalScrollPosChanged(int)));
QObject::connect(horizontalScrollBar, SIGNAL(valueChanged(int)),
this, SLOT(horizontalScrollBarPositionChanged(int)));
QObject::connect(verticalScrollBar, SIGNAL(valueChanged(int)),
this, SLOT(verticalScrollBarPositionChanged(int)));
layout->addWidget(minesFieldWidget, 0, 0);
layout->addWidget(verticalScrollBar, 0, 1);
layout->addWidget(horizontalScrollBar, 1, 0);
setLayout(layout);
}
MinesFieldWidget* MinesFieldScrollableWidget::getMinesFieldWidget() const
{
return minesFieldWidget;
}
bool MinesFieldScrollableWidget::eventFilter(QObject*, QEvent*)
{
return false;
}
void MinesFieldScrollableWidget::horizontalScrollBarPositionChanged(int)
{
horizontalScrollBar->setValue(0);
}
void MinesFieldScrollableWidget::verticalScrollBarPositionChanged(int)
{
verticalScrollBar->setValue(0);
}