Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt, non-modal dialog doesn't close itself

Tags:

dialog

qt

pyqt

I have one main Window and one non-modal Dialog. I suppose non-modal dialog should close itself when I close main window. Instead if I open non-modal dialog, I should close manually both of them - if I close main window, non-modal dialog will remain, and I need to close it manually.

# App and main window
app = QtGui.QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())

class Window ... :
   ...
   def func:
      non_modal_dialog = NonModalDialog()
      non_modal_dialog.show()
   ...

What should I do so when I close main window all non-modal dialogs will be closed automatically?

Thank you.

like image 632
demalexx Avatar asked Feb 07 '10 12:02

demalexx


1 Answers

Have you made the dialog's parent widget the main window or at least some sort of descendant of the main window? If you do that then the dialog will go away when the window does. I'm familiar with Qt but not Python but it didn't look like that's the case from your code sample.

like image 154
Troubadour Avatar answered Oct 25 '22 17:10

Troubadour