How to initialize module widget at application startup

Thank you, good to know.

What is a best way to initialize a module’s widget when Slicer CAT is started?

For example I have a qSlicerStackLoadModule and qSlicerStackLoadModuleWidget classes. I can see that qSlicerStackLoadModule is initialized when Slicer is launched. But the qSlicerStackLoadModuleWidget is initialized when the module is manually chosen in Slicer’s module toolbar via function qSlicerStackLoadModule::createWidgetRepresentation().

I’m looking for a way to instantiate qSlicerStackLoadModuleWidget when qSlicerStackLoadModule is initialized (or more generally when the app is launched). I have tried some things but they either don’t work (Slicer stops launching) or have some lacks.

Modules should be functional without any GUI, to make sure that they work correctly when used for batch processing (then there may be no application GUI at all) or when used from other modules.

If there are any features that must be initialized at startup then those should be implemented in the module logic. If there are special “always-on” GUI elements, such as a toolbar then those can be initialized from the module class (which is a Qt class).

1 Like