# Is there any way to know if a vtkMRMLNode has been renamed?

**URL:** <https://discourse.slicer.org/t/is-there-any-way-to-know-if-a-vtkmrmlnode-has-been-renamed/45717>\
**Category:** Development\
**Tags:** mrml\
**Created:** [January 9, 2026, 10:34am UTC](https://discourse.slicer.org/t/is-there-any-way-to-know-if-a-vtkmrmlnode-has-been-renamed/45717 "2026-01-09T10:34:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suhaim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/suhaim/32/81421_2.png) [@Suhaim](https://discourse.slicer.org/u/Suhaim)\
**Post date:** [January 9, 2026, 10:34am UTC](https://discourse.slicer.org/t/is-there-any-way-to-know-if-a-vtkmrmlnode-has-been-renamed/45717/1 "2026-01-09T10:34:02Z")

</div>

Hi all,  
If you create a markup node(vtkMRMLMarkupsNode) and add control points to it, the control points are named using a default format(“%N-%d”) with respect to the current name of the markup node.

Renaming a markup node doesn’t modify the names of the existing control points of the respective markup. If there was any event in [vtkMRMLMarkupsNode](https://apidocs.slicer.org/main/classvtkMRMLMarkupsNode.html#a3b63d658dab9d501e4104fb6e3da24b0) or its parents that fires when the node is renamed, I could react to it and update the labels.

I was able to achieve what I wanted using **[vtkCommand::ModifiedEvent;](https://vtk.org/doc/nightly/html/classvtkCommand.html#a59a8690330ebcb1af6b66b0f3121f8fea534a769a2e6b5cc199c2b40a78665896)** however, this event also fires for several other cases. I just wanted to ask if there was an event I missed, so that my function is not called for every vtkCommand::ModifiedEvent and is more optimized.

Thanks!

---

<div class="post-metadata">

**Author:** ![ebrahim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebrahim/32/13403_2.png) [@ebrahim](https://discourse.slicer.org/u/ebrahim)\
**Post date:** [January 9, 2026, 1:33pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-know-if-a-vtkmrmlnode-has-been-renamed/45717/2 "2026-01-09T13:33:22Z")

</div>

I don’t see a name change event [here](https://github.com/Slicer/Slicer/blob/963ef4e4c0bb277a33f6b0c610f5e481521ca9ec/Libs/MRML/Core/vtkMRMLMarkupsNode.h#L234) or elsewhere so I think I agree with the way you approached it.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 10, 2026, 5:58pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-know-if-a-vtkmrmlnode-has-been-renamed/45717/3 "2026-01-10T17:58:39Z")

</div>

What would you like to achieve? Rename all the other control points if the user renames one control point (e.g., user specifies for one vertebra that it is T5 and you want to update the labels for all the others accordingly)?

---

<div class="post-metadata">

**Author:** ![Suhaim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/suhaim/32/81421_2.png) [@Suhaim](https://discourse.slicer.org/u/Suhaim)\
**Post date:** [January 12, 2026, 4:14am UTC](https://discourse.slicer.org/t/is-there-any-way-to-know-if-a-vtkmrmlnode-has-been-renamed/45717/4 "2026-01-12T04:14:30Z")

</div>

Hi @lassoan, what I wanted to achieve was :-

1. Let’s say a line markup node name “L\_1” has been created and two control points were added to it.
2. Programatically I rename these two control points as L\_1-entry, L\_1-target respectively when they get defined.
3. If the user renames the line as “L\_2”, I want the control point’s names to change to L\_2-entry and L\_2-target.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 12, 2026, 5:31pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-know-if-a-vtkmrmlnode-has-been-renamed/45717/5 "2026-01-12T17:31:17Z")

</div>

Thanks for the additional information. There is no separate event for node rename, but you can easily fulfill your needs without it.

A simple option is to do a delayed update whenever a node is changed: add an observer to the `Modified` event of all the markup nodes you are interested and connect that to reset of a single-shot QTimer with a short timeout (500ms whenever). In the timer callback check if the markup control point names are up-to-date and update them if needed.

You can avoid this if you capture the node rename event in the GUI. For example, the [qMRMLNodeComboBox](https://apidocs.slicer.org/main/classqMRMLNodeComboBox.html) widget emits a signal if the user rename the current node. You also get notified about a node rename if you add a dedicated button for it in your module GUI.

It would not be hard to implement auto-rename of control points that were named using the “default name format” whenever a node name changes; or add a node renamed event to vtkMRMLNode, but the need just has not come up frequently enough and there are alternative solutions.

---

<div class="post-metadata">

**Author:** ![Suhaim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/suhaim/32/81421_2.png) [@Suhaim](https://discourse.slicer.org/u/Suhaim)\
**Post date:** [January 13, 2026, 3:55am UTC](https://discourse.slicer.org/t/is-there-any-way-to-know-if-a-vtkmrmlnode-has-been-renamed/45717/6 "2026-01-13T03:55:36Z")

</div>

Thanks @lassoan for the detailed explanation and the alternatives suggested, this helps a lot!
