slider.h
1.47 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
#ifndef SLIDER_H
#define SLIDER_H
#include <QWidget>
#include <QPixmap>
class Slider : public QWidget
{
Q_OBJECT
bool isSliderDown_;
int sliderPosition_;
int value_;
int minimum_;
int maximum_;
QPixmap groove;
QPixmap sub;
QPixmap handle;
int grooveMin;
int grooveMax;
QPoint groovePoint;
QPoint subPoint;
bool subVisible_;
public:
explicit Slider(QWidget *parent = 0);
void setSubPixmap(const QPixmap &pixmap);
void setSubPixmap(const QString &fileName);
void setSubVisible(bool visible);
void setRange(int min, int max);
void setMinimum(int min);
void setMaximum(int max);
int value();
int minimum();
int maximum();
bool isSliderDown();
int sliderPosition();
void setSliderPosition(int value);
QList<int> ticks;
QList<int> bigTicks;
int tickInterval;
int bigTickInterval;
protected:
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void paintEvent(QPaintEvent *event);
virtual void resizeEvent(QResizeEvent *event);
private:
int calcSliderPosition(int mouseX);
int calcSubLength(int value);
void updatePixmapPosition();
signals:
void sliderMoved(int value);
void valueChanged(int value);
void sliderPressed();
void sliderReleased();
public slots:
void setValue(int value);
};
#endif // SLIDER_H