1
/********************************************************************************
2
**
3
**  GNU General Public License Usage
4
**
5
**  This program is free software: you can redistribute it and/or modify
6
**  it under the terms of the GNU General Public License as published by
7
**  the Free Software Foundation, either version 3 of the License, or
8
**  (at your option) any later version.
9
**
10
**  This program is distributed in the hope that it will be useful,
11
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
**  GNU General Public License for more details.
14
**
15
**  You should have received a copy of the GNU General Public License
16
**  along with this program. If not, see <http://www.gnu.org/licenses/>.
17
**
18
********************************************************************************/
19
20
#ifndef CUSTOM_ITEM_H
21
#define CUSTOM_ITEM_H
22
23
#include <QGraphicsItem>
24
#include <QPainter>
25
#include <QWidget>
26
#include <QGraphicsSceneMouseEvent>
27
#include <QDebug>
28
29
class CustomItem : public QGraphicsItem
30
{
31
32
public:
33
    CustomItem(QGraphicsItem *parent = 0);
34
35
    QRectF boundingRect() const
36
    {
37
        return QRectF(0, 0, 250, 250);
38
    }
39
40
    void paint(QPainter *painter,
41
               const QStyleOptionGraphicsItem *,
42
               QWidget *)
43
    {
44
        painter->setRenderHint(QPainter::Antialiasing);
45
        painter->setBrush(Qt::blue);
46
47
        painter->drawRoundedRect(0, 0, 250, 250, 5, 5);
48
    }
49
50
protected:
51
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
52
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
53
};
54
55
#endif