C++ (Qt)//------------------------------------------------------------------------------Node::Node(){ nodeTextColor = Qt::blue; nodeForegroundColor = Qt::darkCyan; nodeBackgroundColor = QColor(254, 247, 175); //NOTE: Для генерации события ItemPositionHasChanged нужен флаг ItemSendsGeometryChanges! setFlags(ItemIsMovable | ItemIsSelectable | ItemSendsGeometryChanges);} //------------------------------------------------------------------------------QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value){ if (change == ItemPositionHasChanged) { foreach (Edge *edge, nodeEdges) edge->trackNodes(); } return QGraphicsItem::itemChange(change, value);}
C++ (Qt)QGraphicsItem::mousePressEvent(event);