-
Notifications
You must be signed in to change notification settings - Fork 9
/
mycoolbar.h
71 lines (58 loc) · 1.37 KB
/
mycoolbar.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
66
67
68
69
70
71
#ifndef MYCOOLBAR_H
#define MYCOOLBAR_H
#include <QWidget>
#include <QtGui>
const int BAR_HEIGHT=25;
const int INDICATOR_RADIUS=qRound(1.0*BAR_HEIGHT/2)+1;
const int RECT_RADIUS =10;
const int LEFT_WIDTH=20;
const int RIGHT_WIDTH=LEFT_WIDTH;
class myCoolBar : public QWidget
{
Q_OBJECT
public:
explicit myCoolBar(QWidget *parent = 0);
void setRange(int min,int max);
void setValue(int value);
protected:
void paintEvent(QPaintEvent *);
QSize sizeHint() const
{
return QSize(300,30);
}
QSize minimumSizeHint() const
{
return QSize(200,30);
}
void mousePressEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void resizeEvent(QResizeEvent *);
private:
void drawBackground(QPainter* painter);
void drawBar(QPainter* painter);
void drawIndicator(QPainter* painter);
void drawFilledRegion(QPainter* painter);
private:
qreal m_indicatorPos;
int m_Max;
int m_Min;
int m_value;
qreal m_increment;
qreal m_indicatorY;
qreal m_indicatorX;
QRectF m_barRect;
QRectF m_indicatorRect;
QRectF m_leftRect;
QPointF m_lastPot;
bool m_pressed;
bool m_valid;
bool m_firstRun;
QTimer* updateTimer;
private:
void initVariables();
signals:
void valueChanged(int value);
public slots:
};
#endif // MYCOOLBAR_H