# Hiding nodes from qMRMLSubjectHierarchyTreeView widget

**URL:** <https://discourse.slicer.org/t/hiding-nodes-from-qmrmlsubjecthierarchytreeview-widget/44019>\
**Category:** Development\
**Tags:** subject-hierarchy\
**Created:** [August 8, 2025, 4:01am UTC](https://discourse.slicer.org/t/hiding-nodes-from-qmrmlsubjecthierarchytreeview-widget/44019 "2025-08-08T04:01:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Victor\_Wayne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/victor_wayne/32/80778_2.png) [@Victor\_Wayne](https://discourse.slicer.org/u/Victor_Wayne)\
**Post date:** [August 8, 2025, 4:01am UTC](https://discourse.slicer.org/t/hiding-nodes-from-qmrmlsubjecthierarchytreeview-widget/44019/1 "2025-08-08T04:01:09Z")

</div>

Hello,

I inspected the Data module and found out that it is using qMRMLSubjectHierarchyTreeView widget for showing the nodes in a tree view. I wanted to customize the Data module by creating my own custom widget. So I created a widget, with a combo box that selects from the list plans. The plans contains lines. I want to show the lines like a list and with all the added functionality of hide/show `eye` button, transformation tracking, color picking, and their IDs like how the Data module shows it. So I created one instance of qMRMLSubjectHierarchyTreeView, and set it like this.

```python
self.lineDetailView = qMRMLSubjectHierarchyTreeView()
self.lineDetailView.setMRMLScene(slicer.mrmlScene)

```

The problem is that it shows all the nodes and folders. I just want to show the line that corresponds to the selected plan. I thought I could do the following

```python
self.lineDetailView.nodeTypes = ['vtkMRMLMarkupsLineNode']

```

but this shows the folders with the lines. even if it didn’t show the folders, I don’t know how to delete the other line nodes that doesn’t belong to the current selected plan.

Is there a way to hide any node, be it a folder node or a segmentation node or a line node using its ID from the tree view? I just to want to hide from the tree view. not from the scene.

Any help will be appreciated. Thank you for replying to me.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [August 8, 2025, 9:25am UTC](https://discourse.slicer.org/t/hiding-nodes-from-qmrmlsubjecthierarchytreeview-widget/44019/2 "2025-08-08T09:25:49Z")

</div>

Have you looked at the available filtering options as I suggested in the other thread?

> <https://github.com/Slicer/Slicer/blob/main/Modules/Loadable/SubjectHierarchy/Widgets/qMRMLSubjectHierarchyTreeView.h#L87-L106>

All it takes is a bit of creativity. For example you can set the plan name or some other ID as an attribute to the lines, and you can filter by attribute when you select a plan.

---

<div class="post-metadata">

**Author:** ![Victor\_Wayne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/victor_wayne/32/80778_2.png) [@Victor\_Wayne](https://discourse.slicer.org/u/Victor_Wayne)\
**Post date:** [August 13, 2025, 4:15am UTC](https://discourse.slicer.org/t/hiding-nodes-from-qmrmlsubjecthierarchytreeview-widget/44019/3 "2025-08-13T04:15:57Z")

</div>

Yes, I did exactly what you told here. I attached the plan name itself as an attribute to the line and then I filtered it whenever the combo box text changes. These lines have segmentation nodes attached to it. I now have to show the segmentation nodes below the appropriate line like a tree view. Are there any functions for that?

Thank you very much for your help btw.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [August 13, 2025, 8:51am UTC](https://discourse.slicer.org/t/hiding-nodes-from-qmrmlsubjecthierarchytreeview-widget/44019/4 "2025-08-13T08:51:58Z")

</div>

I’d probably organize all nodes that belong to a plan in folders, and filter the folders.

But I feel like I know too little about the use case to give you a comprehensive answer.
