I am developing a plugin which uses “qMRMLMarkupsROIWidget” inside of it. However, I do not want the user to be able to change the ROI type to anything but “Box”. Additionally, I prefer to remove the checkbox labelled as “Inside out:”
I looked into the documentation and could not find how to do it. Would you please help me with it?
We don’t guarantee that the child widget names and types remain the same in future Slicer versions, so the ideal solution would be to add flags to the qMRMLMarkupsROIWidget to show/hide these components, but using the code snippet above is probably sufficient for now.
Thanks! Sounds reasonable. For what it’s worth, one can also iterate over all the children and find the relevant element using the element type and label for instance. It will make the solution immune to name changes!
You have to use the Qt object name to identify a widget. Label or other text is not suitable for several reasons, for example not all widgets have some constant text label, and even if they have, the label is language dependent (your script would break if someone changes the application language).
Widget class (QLabel, etc.) is indeed redundant. You don’t have to specify it if for example you use a Slicer helper function (or somewhat more complex Qt API). I just wanted to keep things simple show in my above example that there is nothing Slicer-specific about all these. Anyway, if you find the above code inconvenient then you can do this instead:
widget = slicer.qMRMLMarkupsROIWidget()
for name in ["label", "insideOutCheckBox", "label_10", "roiTypeComboBox"]:
slicer.util.findChild(widget, name).hide()
widget.show()