triggering main window exit when exiting from qdialog window


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”

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

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

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.