Show type of Node in SubjectHierarchyTreeView

Hello,
I Would like to show only ““vtkMRMLMarkupsFiducialNode”” in my SubjectHierarchyTreeView widget.
I manage to hide the majority of node types thanks to this snipet :slight_smile:

self.shFiducialTreeView = slicer.qMRMLSubjectHierarchyTreeView()
self.shFiducialTreeView.nodeTypes = ["vtkMRMLMarkupsFiducialNode"]
self.shFiducialTreeView.setShowRootItem(False)
self.shFiducialTreeView.setMRMLScene(slicer.mrmlScene)

But as you can some folder Nodes are still showing :

image

Do you have a solution for this issue ? what am i doing wrong ?

Thanks a lot

Folders are shown by default (even if they are empty), because otherwise you could not create new folders and drag-and-drop nodes into them. In recent Slicer Preview Releases you can control visibility of empty folders.

For that you need to do the following:

proxyModel = self.shFiducialTreeView.sortFilterProxyModel()
proxyModel.showEmptyHierarchyItems = False
1 Like

Hello tanks for this python code

unfortunatly i have an error
AttributeError: 'showEmptyHierarchyItems' does not exist on qMRMLSortFilterSubjectHierarchyProxyModel and creating new attributes on C++ objects is not allowed

My version is 4.11 what should i do ?

Install the latest preview version.