File: graphlabelwidget.h

package info (click to toggle)
apitrace 7.1%2Bgit20170623.d38a69d6%2Brepack-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 15,992 kB
  • sloc: cpp: 179,347; ansic: 62,439; python: 33,058; java: 377; makefile: 105; sh: 26; xml: 26
file content (39 lines) | stat: -rw-r--r-- 780 bytes parent folder | download | duplicates (6)
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 *) override
    {
        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;
};