blob: 050dc40dbb7ed5499cb4f600da4e79049bf7d13a (
plain)
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
|
#pragma once
#include <QWidget>
#include <QPainter>
/**
* A very simple label widget, basically a box with text in.
*/
class GraphLabelWidget : public QWidget {
public:
GraphLabelWidget(QString text = QString(), QWidget* parent = 0) :
QWidget(parent),
m_flags(Qt::AlignHCenter | Qt::AlignVCenter),
m_text(text)
{
}
void setText(const QString& text)
{
m_text = text;
}
void setFlags(int flags)
{
m_flags = flags;
}
virtual void paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(Qt::black);
painter.fillRect(rect(), Qt::lightGray);
painter.drawText(rect(), m_flags, m_text);
}
protected:
int m_flags;
QString m_text;
};
|