# Subject hierarchy combobox showing a drop-down tree

**URL:** <https://discourse.slicer.org/t/subject-hierarchy-combobox-showing-a-drop-down-tree/733>\
**Category:** Development\
**Tags:** documentation, designer\
**Created:** [July 20, 2017, 8:11pm UTC](https://discourse.slicer.org/t/subject-hierarchy-combobox-showing-a-drop-down-tree/733 "2017-07-20T20:11:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dzenanz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dzenanz/32/1992_2.png) [@dzenanz](https://discourse.slicer.org/u/dzenanz)\
**Post date:** [July 20, 2017, 8:11pm UTC](https://discourse.slicer.org/t/subject-hierarchy-combobox-showing-a-drop-down-tree/733/1 "2017-07-20T20:11:20Z")

</div>

[New features](https://www.slicer.org/wiki/Documentation/Labs/SubjectHierarchy#New_features) section in the documentaion mentions a combobox showing a drop-down tree, but in the designer (started by Slicer-build\Slicer.exe --designer) I only see qMRMLSubjectHierarchyTreeView widget. Is the documentation wrong, or am I doing something wrong?

---

<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:** [July 20, 2017, 9:07pm UTC](https://discourse.slicer.org/t/subject-hierarchy-combobox-showing-a-drop-down-tree/733/2 "2017-07-20T21:07:46Z")

</div>

I think what you need is qMRMLSubjectHierarchyComboBox

---

<div class="post-metadata">

**Author:** ![dzenanz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dzenanz/32/1992_2.png) [@dzenanz](https://discourse.slicer.org/u/dzenanz)\
**Post date:** [July 20, 2017, 9:29pm UTC](https://discourse.slicer.org/t/subject-hierarchy-combobox-showing-a-drop-down-tree/733/3 "2017-07-20T21:29:06Z")

</div>

I don’t see that in Designer, and if I add qMRMLSubjectHierarchyTreeView and then manually change it into qMRMLSubjectHierarchyComboBox (by text editing .ui file), I get the following error at run time:

> AttributeError: QTreeView has no attribute named ‘setMRMLScene’

When was this control added to Slicer? Was it added after qMRMLSubjectHierarchyTreeView?

Edit: _I haven’t updated Slicer in a few weeks._

---

<div class="post-metadata">

**Author:** ![dzenanz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dzenanz/32/1992_2.png) [@dzenanz](https://discourse.slicer.org/u/dzenanz)\
**Post date:** [July 20, 2017, 9:47pm UTC](https://discourse.slicer.org/t/subject-hierarchy-combobox-showing-a-drop-down-tree/733/4 "2017-07-20T21:47:50Z")

</div>

Directly creating it through Python works:  
`shcb=slicer.qMRMLSubjectHierarchyComboBox()`

---

<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:** [July 20, 2017, 10:46pm UTC](https://discourse.slicer.org/t/subject-hierarchy-combobox-showing-a-drop-down-tree/733/5 "2017-07-20T22:46:16Z")

</div>

You cannot make such substitutions in a ui file unless you edit the signals/slots as well (if you do that it should work).

That said you can also very easily create a Qt Deesigner plugin for the combobox widget, see [that of the tree view](https://github.com/Slicer/Slicer/tree/master/Modules/Loadable/SubjectHierarchy/Widgets/DesignerPlugins)

---

<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:** [July 21, 2017, 3:52am UTC](https://discourse.slicer.org/t/subject-hierarchy-combobox-showing-a-drop-down-tree/733/6 "2017-07-21T03:52:33Z")

</div>

Yes, you just need to add two files (copy&paste + find&replace, no thinking is needed) and add them to CMakeLists.txt. Pull request would be very welcome.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dzenanz/32/1992_2.png) [@dzenanz](https://discourse.slicer.org/u/dzenanz)\
**Post date:** [July 21, 2017, 5:19pm UTC](https://discourse.slicer.org/t/subject-hierarchy-combobox-showing-a-drop-down-tree/733/7 "2017-07-21T17:19:32Z")

</div>

Thanks for pointing me to the right place. I will probably make a PR for it next week.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/dzenanz/32/1992_2.png) [@dzenanz](https://discourse.slicer.org/u/dzenanz)\
**Post date:** [July 22, 2017, 6:06pm UTC](https://discourse.slicer.org/t/subject-hierarchy-combobox-showing-a-drop-down-tree/733/8 "2017-07-22T18:06:32Z")

</div>

[Pull request](https://github.com/Slicer/Slicer/pull/748) created.

---

<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:** [July 23, 2017, 2:08am UTC](https://discourse.slicer.org/t/subject-hierarchy-combobox-showing-a-drop-down-tree/733/9 "2017-07-23T02:08:48Z")

</div>

The pull request is merged. Thank you!

---

<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:** [July 23, 2017, 3:11pm UTC](https://discourse.slicer.org/t/subject-hierarchy-combobox-showing-a-drop-down-tree/733/10 "2017-07-23T15:11:10Z")

</div>

Thank you, @dzenanz!
