# How to add the Subject hierarchy tree to a custom extension

**URL:** <https://discourse.slicer.org/t/how-to-add-the-subject-hierarchy-tree-to-a-custom-extension/22980>\
**Category:** Development\
**Created:** [April 15, 2022, 9:18pm UTC](https://discourse.slicer.org/t/how-to-add-the-subject-hierarchy-tree-to-a-custom-extension/22980 "2022-04-15T21:18:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![koeglfryderyk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/koeglfryderyk/32/14638_2.png) [@koeglfryderyk](https://discourse.slicer.org/u/koeglfryderyk)\
**Post date:** [April 15, 2022, 9:18pm UTC](https://discourse.slicer.org/t/how-to-add-the-subject-hierarchy-tree-to-a-custom-extension/22980/1 "2022-04-15T21:18:56Z")

</div>

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):

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/4/443831ac72f89866276be0846b5b71e52afbdcfd.png)

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

---

<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:** [April 16, 2022, 12:25am UTC](https://discourse.slicer.org/t/how-to-add-the-subject-hierarchy-tree-to-a-custom-extension/22980/2 "2022-04-16T00:25:36Z")

</div>

You need to set the scene into the widget.

---

<div class="post-metadata">

**Author:** ![koeglfryderyk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/koeglfryderyk/32/14638_2.png) [@koeglfryderyk](https://discourse.slicer.org/u/koeglfryderyk)\
**Post date:** [April 16, 2022, 3:07pm UTC](https://discourse.slicer.org/t/how-to-add-the-subject-hierarchy-tree-to-a-custom-extension/22980/3 "2022-04-16T15:07:26Z")

</div>

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)`
