Skip to content

Commit c534f44

Browse files
committed
Add a guide to change notifications and describe the Size role
The guide explains who notifies whom when the graph changes, with Mermaid diagrams. It needs sphinxcontrib-mermaid. NodeRole::Size has one description in the header, the roles table, the setNodeData comment and the advanced guide: it is the layout size that the geometry computes, and the model only stores it. It is not an input. The old advice to emit nodeUpdated when Size is set made an endless recursion and is removed.
1 parent cd0051c commit c534f44

8 files changed

Lines changed: 373 additions & 6 deletions

File tree

‎docs/conf.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def configureDoxyfile(input_dir, output_dir):
4545
# Add any Sphinx extension module names here, as strings. They can be
4646
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4747
# ones.
48-
extensions = [ "breathe", "sphinx_rtd_theme" ]
48+
extensions = [ "breathe", "sphinx_rtd_theme", "sphinxcontrib.mermaid" ]
4949

5050

5151
#Breathe configuration

‎docs/guide/advanced.rst‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ Update at runtime:
122122
Resizable Nodes
123123
---------------
124124

125-
Allow users to resize nodes (useful for embedded widgets):
125+
Allow users to resize nodes (useful for embedded widgets). A resizable node shows a resize
126+
handle. The handle resizes the embedded widget, and the node follows its widget:
126127

127128
.. code-block:: cpp
128129
@@ -131,20 +132,30 @@ Allow users to resize nodes (useful for embedded widgets):
131132
return NodeFlag::Resizable;
132133
}
133134
134-
Handle size changes:
135+
The scene computes the size of a node from its content: the widget, the caption, the label and
136+
the ports. It stores the result with ``setNodeData(nodeId, NodeRole::Size, size)``. Your model
137+
must store this value and return it. It is an output of the layout and not a setting. A value
138+
that you set from code does not resize the node, and the next ``nodeUpdated`` replaces it. To
139+
make a node bigger, resize its embedded widget. If the delegate resizes the widget itself, it
140+
emits ``embeddedWidgetSizeUpdated()`` afterwards.
141+
142+
Store the size:
135143

136144
.. code-block:: cpp
137145
138146
bool MyModel::setNodeData(NodeId nodeId, NodeRole role, QVariant value) override
139147
{
140148
if (role == NodeRole::Size) {
141149
_nodeSizes[nodeId] = value.toSize();
142-
emit nodeUpdated(nodeId);
143150
return true;
144151
}
145152
// ...
146153
}
147154
155+
Do not emit ``nodeUpdated`` when ``Size`` is set. The scene sets ``Size`` while it handles
156+
``nodeUpdated``, so the signal would start an endless recursion. See
157+
:doc:`change-notifications` for the signals that a model must emit.
158+
148159
Non-Detachable Connections
149160
--------------------------
150161

0 commit comments

Comments
 (0)