-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVideoSlider.cpp
70 lines (48 loc) · 1.25 KB
/
VideoSlider.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "VideoSlider.h"
#include <QDebug>
#include <QTimer>
#include <QResizeEvent>
#include <QStyle>
VideoSlider::VideoSlider(QWidget *parent) :
QSlider(parent)
{
setMouseTracking(true);
this->setOrientation(Qt::Horizontal);
isSliderMoving = false;
}
VideoSlider::~VideoSlider()
{
}
void VideoSlider::mousePressEvent(QMouseEvent *event)
{
m_posX = event->pos().x();
double curr_x = double(m_posX);
double curr_total = double(width());
double ratio = curr_x/curr_total;
int value = QStyle::sliderValueFromPosition(minimum(), maximum(), event->pos().x(), width());
setValue(value);
qDebug()<<"点击的地方"<<this->value();
emit sig_valueChanged(ratio);
emit sig_valueChanged_v((qint64)this->value());
emit sig_pressed();
}
void VideoSlider::mouseMoveEvent(QMouseEvent *event)
{
m_posX = event->pos().x();
double curr_x = double(m_posX);
double curr_total = double(width());
double ratio = curr_x/curr_total;
pointingRatio = ratio;
emit sig_moveValueChanged(ratio);
QSlider::mouseMoveEvent(event);
}
void VideoSlider::leaveEvent(QEvent *)
{
qDebug()<<"leave";
emit sig_mouseLeave();
}
void VideoSlider::setValue(int value)
{
QSlider::setValue(value);
}