-
Notifications
You must be signed in to change notification settings - Fork 0
/
doubleslider.h
65 lines (49 loc) · 1.32 KB
/
doubleslider.h
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
#ifndef DOUBLESLIDER_H
#define DOUBLESLIDER_H
#include <QWidget>
#include<QObject>
#include<QPainter>
#include<QMouseEvent>
#include<QLineEdit>
#include<QLayout>
class DoubleSlider : public QWidget
{
Q_OBJECT
public:
DoubleSlider(QWidget* parent = 0);
void setRange(float min, float max);
void setSingleStep(float step);
void setMaxRange(float range);
void setMinRange(float range);
enum State{ MinHandle,MaxHandle,None};
float minValue() const;
float maxValue() const;
float minRange() const;
float maxRange() const;
public slots:
void setLabel(const QString& label);
void setMaxValue(float val);
void setMinValue(float val);
signals:
void minValueChanged(float);
void maxValueChanged(float);
private:
float m_min;
float m_max;
float m_singleStep;
float m_minValue;
float m_maxValue;
QRect minHandleRegion;
QRect maxHandleRegion;
State m_state;
QString m_label;
protected:
void paintEvent(QPaintEvent* event);
void paintColoredRect(QRect rect, QColor color, QPainter* painter);
void paintValueLabel(QPainter* painter);
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent *event);
void leaveEvent(QEvent* event);
};
#endif // DOUBLESLIDER_H