# triggering main window exit when exiting from qdialog window

**URL:** <https://discourse.slicer.org/t/triggering-main-window-exit-when-exiting-from-qdialog-window/30373>\
**Category:** Development\
**Created:** [July 3, 2023, 3:59pm UTC](https://discourse.slicer.org/t/triggering-main-window-exit-when-exiting-from-qdialog-window/30373 "2023-07-03T15:59:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pcg12131415](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@pcg12131415](https://discourse.slicer.org/u/pcg12131415)\
**Post date:** [July 3, 2023, 3:59pm UTC](https://discourse.slicer.org/t/triggering-main-window-exit-when-exiting-from-qdialog-window/30373/1 "2023-07-03T15:59:50Z")

</div>

Hi!

I have a Slicer module that opens a different window (using QDialog) from the Slicer main one. I would like to connect the two of them in order to close Slicer when the second one gets closed.  
I saw I could override some methods in QDialog (like closeEvent()), but I guess I can’t since I am importing it in the Widget class from the UI file through:  
self.uiWidget = slicer.util.loadUI(self.resourcePath(‘UI/Module.ui’))

This is the QDialog creation in the UI file (cutting out ‘\>’ and ‘\<’):

widget class=“QDialog” name=“Module”  
property name=“windowModality”  
enum\>Qt::ApplicationModal\</enum

is there a way to trigger the closing of Slicer from the Logic of the second window?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 3, 2023, 5:14pm UTC](https://discourse.slicer.org/t/triggering-main-window-exit-when-exiting-from-qdialog-window/30373/2 "2023-07-03T17:14:41Z")

</div>

You should be able to get a signal from the QDialog and call `slicer.util.exit()` to exit the app.

---

<div class="post-metadata">

**Author:** ![pcg12131415](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@pcg12131415](https://discourse.slicer.org/u/pcg12131415)\
**Post date:** [July 5, 2023, 3:29pm UTC](https://discourse.slicer.org/t/triggering-main-window-exit-when-exiting-from-qdialog-window/30373/3 "2023-07-05T15:29:58Z")

</div>

I found the reason, i was defining the signal connection after the qdialog exec() (this was in an external function so i had no idea), therefore it wasn’t seen.
