-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseekslider.cpp
More file actions
28 lines (21 loc) · 792 Bytes
/
seekslider.cpp
File metadata and controls
28 lines (21 loc) · 792 Bytes
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
#include "seekslider.h"
SeekSlider::SeekSlider(QWidget *parent)
: QSlider(parent) {
setOrientation(Qt::Horizontal);
}
SeekSlider::SeekSlider(Qt::Orientation orientation, QWidget *parent)
: QSlider(orientation, parent) {}
void SeekSlider::mousePressEvent(QMouseEvent *event) {
if (event->button() == Qt::LeftButton) {
QStyleOptionSlider opt;
initStyleOption(&opt);
if (orientation() == Qt::Horizontal) {
int width = opt.rect.width();
int newX = event->pos().x();
int newValue = QStyle::sliderValueFromPosition(minimum(), maximum(), newX, width, false);
setValue(newValue);
emit sliderReleased();
}
}
QSlider::mousePressEvent(event);
}