Skip to content

Commit

Permalink
Update embedded QWidget position after node update
Browse files Browse the repository at this point in the history
  • Loading branch information
nolankramer authored and paceholder committed Aug 16, 2024
1 parent 4ac0857 commit 77f3ad1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/QtNodes/internal/NodeGraphicsObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class NodeGraphicsObject : public QGraphicsObject
/// Repaints the node once with reacting ports.
void reactToConnection(ConnectionGraphicsObject const *cgo);

void updateQWidgetEmbedPos();

protected:
void paint(QPainter *painter,
QStyleOptionGraphicsItem const *option,
Expand Down
1 change: 1 addition & 0 deletions src/BasicGraphicsScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ void BasicGraphicsScene::onNodeUpdated(NodeId const nodeId)

_nodeGeometry->recomputeSize(nodeId);

node->updateQWidgetEmbedPos();
node->update();
node->moveConnections();
}
Expand Down
7 changes: 6 additions & 1 deletion src/NodeGraphicsObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ BasicGraphicsScene *NodeGraphicsObject::nodeScene() const
return dynamic_cast<BasicGraphicsScene *>(scene());
}

void NodeGraphicsObject::updateQWidgetEmbedPos()
{
_proxyWidget->setPos(nodeScene()->nodeGeometry().widgetPosition(_nodeId));

This comment has been minimized.

Copy link
@OpenJeDi

OpenJeDi Aug 30, 2024

This crashes on my system: _proxyWidget can be nullptr

}

void NodeGraphicsObject::embedQWidget()
{
AbstractNodeGeometry &geometry = nodeScene()->nodeGeometry();
Expand All @@ -99,7 +104,7 @@ void NodeGraphicsObject::embedQWidget()
_proxyWidget->setMinimumHeight(widgetHeight);
}

_proxyWidget->setPos(geometry.widgetPosition(_nodeId));
updateQWidgetEmbedPos();

//update();

Expand Down

0 comments on commit 77f3ad1

Please sign in to comment.