void Node dragEnterEvent QGraphicsSceneDragDr opEvent event if event-

 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
void Node::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
{
if (event->mimeData()->hasColor()){
event->setAccepted(true);
dragOver = true;
update();
} else {
event->setAccepted(false);
}
}
void Node::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
{
Q_UNUSED(event);
dragOver = false;
update();
}
void Node::dropEvent(QGraphicsSceneDragDropEvent *event)
{
dragOver = false;
if (event->mimeData()->hasColor())
color = qVariantValue<QColor>(event->mimeData()->colorData());
else if (event->mimeData()->hasImage())
pixmap = qVariantValue<QPixmap>(event->mimeData()->imageData());
update();
this->xpos = this->x();
this->ypos = this->y();
}