summaryrefslogtreecommitdiffstats
path: root/examples/animation/stickman/rectbutton.cpp
blob: f8b00daa9df52aae421238df3bcb20a1f3f3e9b0 (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
#include "rectbutton.h"
#include <QPainter>

RectButton::RectButton(QString buttonText) : m_ButtonText(buttonText)
{
}


RectButton::~RectButton()
{
}


void RectButton::mousePressEvent (QGraphicsSceneMouseEvent *event)
{
    emit clicked();
}


QRectF RectButton::boundingRect() const
{
    return QRectF(0.0, 0.0, 90.0, 40.0);
}


void RectButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->setBrush(Qt::gray);
    painter->drawRoundedRect(boundingRect(), 5, 5);

    painter->setPen(Qt::white);
    painter->drawText(20, 25, m_ButtonText);
}