Widget with label: size issue after text update
yvanblanchard opened this issue · 3 comments
yvanblanchard commented
Hello,
I have an embedded widget in a custom node, containing a layout and a frame with text.
When initializing the widgets, the frame size is OK (fully inside node):
But when updating the text of the label (after clicking on it, through code in click event), the size is KO (label is out of node perimeter):
Thank you for your help..
Trzeth commented
Hi yvanblanchard, i figure it out and find quite easy.
If you're using deafult DataFlowGraphModel and DataFlowGraphicsScene like me, everything is almost ok.
This work is based on main brach commit 5465ddc
What you need to do is:
- add a Q_SIGNALS in DataFlowGraphModel.hpp named
void embeddedWidgetSizeUpdated(NodeId const);
- connect this in DataFlowGraphModel.cpp in
DataFlowGraphModel::addNode(QString const nodeType)
function withconnect(model.get(),&NodeDelegateModel::embeddedWidgetSizeUpdated,this,[newId, this](){Q_EMIT embeddedWidgetSizeUpdated(newId);});
- PS: You will see lots of connect method there, you can't miss it. ;)
- last step is connect this in DataFlowGraphicsScene.cpp in the constructor with
connect(&_graphModel,&DataFlowGraphModel::embeddedWidgetSizeUpdated,[this](NodeId const nodeId){ onNodeUpdated(nodeId); });
- now you can use
this->embeddedWidgetSizeUpdated();
in your DataModel everytime you change label size.
QiuYilin commented
DataFlowGraphModel.hpp
Q_SIGNALS:
void inPortDataWasSet(NodeId const,PortType const,PortIndex const);
+void outPortDataUpdated(NodeId const)
DataFlowGraphModel.cpp
void DataFlowGraphModel::onOutPortDataUpdated(NodeId const nodeId)
{
+Q_EMIT outPortDataUpdated(nodeId);
...
}
DataFlowGraphicsScene.cpp
+connect(&_graphModel,
+&DataFlowGraphModel::outPortDataUpdated,
+[this](NodeId const nodeId) { onNodeUpdated(nodeId); });
yvanblanchard commented
Thank you