-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchartview.cpp
More file actions
78 lines (69 loc) · 1.71 KB
/
chartview.cpp
File metadata and controls
78 lines (69 loc) · 1.71 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "chartview.h"
#include "chartswidgt.h"
ChartView::ChartView(QChart *chart, QWidget *parent) :
QChartView(chart, parent),
isClicking(false),
xOld(0), yOld(0)
{
//setRubberBand(QChartView::NoRubberBand);
}
void ChartView::mousePressEvent(QMouseEvent *event)
{
qDebug()<<"ChartView"<<"mousePressEvent";
if (event->button() & Qt::RightButton) {
isClicking = true;
}
QChartView::mousePressEvent(event);
}
void ChartView::mouseMoveEvent(QMouseEvent *event)
{
// qDebug()<<"ChartView"<<"mouseMoveEvent";
emit sendposition(event->pos());
int x, y;
if (isClicking) {
if (xOld == 0 && yOld == 0) {
} else {
x = event->x() - xOld;
y = event->y() - yOld;
chart()->scroll(-x, y);
//emit updateslider();
}
xOld = event->x();
yOld = event->y();
}
QChartView::mouseMoveEvent(event);
}
void ChartView::mouseReleaseEvent(QMouseEvent *event)
{
qDebug()<<"ChartView mouseReleaseEvent";
if (event->button() & Qt::RightButton)
{
if (isClicking) {
xOld = yOld = 0;
isClicking = false;
return;
}
}
QChartView::mouseReleaseEvent(event);
}
void ChartView::keyPressEvent(QKeyEvent *event)
{
// switch (event->key()) {
// case Qt::Key_Left:
// chart()->scroll(-10, 0);
// break;
// case Qt::Key_Right:
// chart()->scroll(10, 0);
// break;
// case Qt::Key_Up:
// chart()->scroll(0, 10);
// break;
// case Qt::Key_Down:
// chart()->scroll(0, -10);
// break;
// default:
// keyPressEvent(event);
// break;
// }
QChartView::keyPressEvent(event);
}