How to get notified in Python when currentItemChanged fires? I tried this:
# myCB1 is qMRMLNodeComboBox
# myCB2 is qMRMLSubjectHierarchyComboBox
def updateMRMLFromGUI(self, **unused):
# gets called for myCB1, but not for myCB2
How to make only volumes selectable, and not studies or patients? For qMRMLNodeComboBox this .ui fragment only shows volumes:
First question: self.usPatientItemCombobox.connect('currentItemChanged(vtkIdType)', self.onUSPatientSelectionChanged)
If you only want to be able to select volumes, then simply use qMRMLNodeComboBox. If you want to see the hierarchy as well, but only have the volumes in the hierarchy show up, then you can easily add a filter similar to the attribute filter in the combobox class
I think the Qt designer plugins are an irrelevant detail for this example
The entities that you show and in this case filter in SH are not nodes, but they are items. It’s important, because for many of the items there is no corresponding MRML node. This may actually confuse people who want to filter in node attribute, when in reality the filter applies on SH item attributes.
Indeed, the screenshot shows that the item does have that attribute. What happens if you set the same filter on the SH tree view? You can get it like this:
If I create a combobox like this (I had a CT in the scene), it works with the latest version:
Basic question but are you sure you set the scene to the combobox?
Another thing to check: Try if it works if you set the attribute before you create the widget (the order should not matter but maybe there is a bug and the tree is not re-filtered when an attribute is changed).