refactor: adjust

This commit is contained in:
parker
2025-06-22 03:18:10 +01:00
parent e00cf4a41d
commit 05f6674a70
8 changed files with 141 additions and 25 deletions

View File

@@ -14,7 +14,7 @@ NodeGraphic::NodeGraphic(QGraphicsItem *parent)
title_ = "hello world";
bodyRect_ = QRect(-10, -10, 10*maxTitleLen_, 20);
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges);
initSockets();
}
@@ -96,3 +96,18 @@ void NodeGraphic::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
}
QVariant NodeGraphic::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == ItemPositionChange && scene()) {
for(auto socket : inputs_)
{
socket->posChanged(value.toPointF());
}
for(auto socket : outputs_)
{
socket->posChanged(value.toPointF());
}
};
return QGraphicsItem::itemChange(change, value);
}