How to add the Subject hierarchy tree to a custom extension

I wanted to have the subject hierarchy as part of my custom extension.

To do this, I added the qMRMLSubjectHierarchyTreeView to my .ui file.

It now appears in my custom extension but it is empty (a scene is loaded and in the data module the tree is there):

What do I have to do to make all the folders, volumes etc appear here?

You need to set the scene into the widget.

1 Like

Thanks, that worked. Just wanted to comment with the line of code if in the future anyone will have the same problem:

(I added this line of code to setup() in the widget class of my extension:
self.ui.SubjectHierarchyTreeView.setMRMLScene(slicer.mrmlScene)

2 Likes