I am updating one of SlicerMorph’s tools with several suggestions that were made by users. During that process, one question occured to me. Is it possible to have a single Collapsible button be shared across multiple tabs in the qt interface?
Currently, we are creating a generic function that adds a button to each tab separately:
But that creates a lot of extra code to make sure the shared parameters are updated in one tab when changed in another one. Any ideas?
What we typically do is associate a widget class with the scene, so that each instance automatically updates when the corresponding elements (e.g. a parameter node) of the scene change. For example the subject hierarchy widgets or the views themselves can have multiple instances and each is responsible for updating the UI when the scene changes or updating the scene in response to UI events. This also gives the option of having multiple instances visible at the same time, possibly with different local configurations.
Something like this would definitely work. From the top of your head, can you think of any Slicer module that has that kind of layout? It would be great to have an example to help visualize it.
No worries if there is no example that comes to mind.
The scripted module template works like this (updates itself from MRML nodes).
If you want to “share” a collapsible button between multiple tabs then it sounds like the collapsible button does not really belong to the tab control, but should be place outside of it (below it, or maybe on one side). This is all trivial if you use Qt Designer. Using this visual editor significantly cuts down the time in implementing and maintaining complex GUI.