-
Notifications
You must be signed in to change notification settings - Fork 9
/
mygauge4.h
74 lines (58 loc) · 1.28 KB
/
mygauge4.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
#ifndef MYGAUGE4_H
#define MYGAUGE4_H
#define INCREMENT2 66
#define LONG2 8
#define OK2 5
#define SHORT2 3
#define TOP_SPACE2 10
#define SPACE2 20
#include <QWidget>
#include <QtGui>
#include <QObject>
class LinearGradient : public QObject
{
Q_OBJECT
public:
explicit LinearGradient(QObject *parent = 0);
public:
static QLinearGradient GetGradient(const QPointF& startPos,const QPointF& endPos,const QColor& clr);
};
class myGauge4 : public QWidget
{
Q_OBJECT
public:
explicit myGauge4(QWidget *parent = 0);
void SetmyLineColor(QColor c);
protected:
void paintEvent(QPaintEvent *);
QSize sizeHint() const
{
return QSize(300,120);
}
private:
void drawTopBottomRects(QPainter* painter);
void drawMark(QPainter *painter);
void drawIndicator(QPainter* painter);
private:
LinearGradient lg;
qreal m_rectHeight;
QRectF m_topRect;
QRectF m_bottomRect;
QRectF m_middleRect;
qreal m_markLength;
qreal m_topY;
qreal m_startX;
qreal m_length;
qreal m_increment;
qreal m_bottomY;
bool m_bReverse;
qreal m_value;
qreal m_currentValue;
QTimer* updateTimer;
QColor mylinecolor;
private slots:
void UpdateGraph();
public slots:
void setValue(qreal value);
};
#endif // MYGAUGE4_H