-
Notifications
You must be signed in to change notification settings - Fork 9
/
mygauge3.h
90 lines (73 loc) · 1.78 KB
/
mygauge3.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef MYGAUGE3_H
#define MYGAUGE3_H
#define LEFT_SPACE1 30
#define TOP_SPACE1 40
#include <QWidget>
#include <QtGui>
class myGauge3 : public QWidget
{
Q_OBJECT
public:
explicit myGauge3(QWidget *parent = 0);
void SetmyTopColor(QColor c);
protected:
void paintEvent(QPaintEvent *);
QSize sizeHint() const
{
return QSize(400,150);
}
QSize minimumSizeHint() const
{
return QSize(300,120);
}
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
void resizeEvent(QResizeEvent *);
private:
void drawBackground(QPainter* painter);
void drawRule(QPainter* painter);
void drawHandle(QPainter* painter);
void drawHorizontalLine(QPainter* painter);
void drawVerticalLines(QPainter* painter);
void resetVariables(QPainter* painter);
void drawTip(QPainter* painter);
private:
int m_nMin;
int m_nMax;
int m_length;
qreal m_value;
qreal m_longHand;
qreal m_okHand;
qreal m_shortHand;
qreal m_handleWidth;
qreal m_handleHeight;
qreal m_indicatorLength;
QPointF m_indicatorTopPot;
QPointF m_indicatorLastPot;
QPointF m_indicatorBottomLeftPot;
QPointF m_indicatorBottomRightPot;
QPointF m_lineLeftPot;
QPointF m_lineRightPot;
QRectF m_handleRect;
QPointF m_lastPos;
QTimer* tipTimer;
QTimer* eraseTimer;
QRectF m_tipRect;
qreal m_currentValue;
bool m_bDrag;
bool m_bShowTip;
QColor myTopColor;
private:
void initVariables();
void initSettings();
private slots:
void ShowTip();
void HideTip();
signals:
void valueChanged(qreal value);
public slots:
void setRange(int min,int max);
void setValue(qreal value);
};
#endif // MYGAUGE3_H