-
Notifications
You must be signed in to change notification settings - Fork 1
/
NodeButton.h
40 lines (34 loc) · 1.04 KB
/
NodeButton.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
#include <QObject>
#include <QGraphicsItem>
#include <QPainter>
#include <QGraphicsRectItem>
#include <QRect>
#include "Trees.h"
#ifndef MYQTPROJECT_NODEBUTTON_H
#define MYQTPROJECT_NODEBUTTON_H
class NodeButton : public QObject, public QGraphicsRectItem {
Q_OBJECT
public:
explicit NodeButton(QObject *parent = nullptr){};
explicit NodeButton(const QRectF & rect, QGraphicsItem * parent = nullptr): QGraphicsRectItem(rect, parent) {}
~NodeButton() = default;
int nodePointer;
signals:
void clickNode(int);
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event){
// QGraphicsItem::mousePressEvent(event);
emit clickNode(nodePointer);
}
private:
virtual QRectF boundingRect() const {
return this->rect();
}
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
painter->setBrush(this->brush());
painter->drawEllipse(this->rect());
Q_UNUSED(option);
Q_UNUSED(widget);
}
};
#endif //MYQTPROJECT_NODEBUTTON_H