Subject hierarchy combobox showing a drop-down tree

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?

I think what you need is qMRMLSubjectHierarchyComboBox

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.

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

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

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.

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

1 Like

Pull request created.

The pull request is merged. Thank you!

Thank you, @dzenanz!