-
Notifications
You must be signed in to change notification settings - Fork 0
/
imagegraphicsviewform.cpp
42 lines (36 loc) · 1.08 KB
/
imagegraphicsviewform.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
#include "imagegraphicsviewform.h"
#include "ui_imagegraphicsviewform.h"
ImageGraphicsViewForm::ImageGraphicsViewForm(QWidget *parent) :
QGraphicsView(parent),
ui(new Ui::ImageGraphicsViewForm)
{
ui->setupUi(this);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
}
ImageGraphicsViewForm::~ImageGraphicsViewForm()
{
delete ui;
}
void ImageGraphicsViewForm::mousePressEvent(QMouseEvent *event)
{
if((event->buttons() & Qt::LeftButton) != 0)
emit signalLeftButtonPressed(mapToScene(event->pos()));
if((event->buttons() & Qt::RightButton) != 0)
emit signalRightButtonPressed();
else
QGraphicsView::mousePressEvent(event);
}
void ImageGraphicsViewForm::mouseMoveEvent(QMouseEvent *event)
{
emit signalMouseMoved(mapToScene(event->pos()));
}
void ImageGraphicsViewForm::wheelEvent(QWheelEvent *event)
{
if(event->delta() > 0)
emit signalWheelScrolledUp();
if(event->delta() < 0)
emit signalWheelScrolledDown();
else
QGraphicsView::wheelEvent(event);
}