# How to initialize module widget at application startup

**URL:** <https://discourse.slicer.org/t/how-to-initialize-module-widget-at-application-startup/19211>\
**Category:** Development\
**Created:** [August 16, 2021, 2:06pm UTC](https://discourse.slicer.org/t/how-to-initialize-module-widget-at-application-startup/19211 "2021-08-16T14:06:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [August 16, 2021, 2:06pm UTC](https://discourse.slicer.org/t/how-to-initialize-module-widget-at-application-startup/19211/1 "2021-08-16T14:06:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 16, 2021, 2:28pm UTC](https://discourse.slicer.org/t/how-to-initialize-module-widget-at-application-startup/19211/2 "2021-08-16T14:28:30Z")

</div>

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).
