[PyQt] QMessagebox in slot terminates application
Darryl Wallace
darryl.wallace at prosensus.ca
Mon Jan 12 18:18:26 GMT 2009
Tim,
This is the more accurate explanation I was looking for!
darryl
Tim Hoffmann wrote:
> Marc Nations schrieb:
>> Yeah, that's more correct. Since the MessageBox is being called
>> indirectly the actual value it returns isn't being utilized.
>>
>> Although now I'm a little confused as to why the app is even
>> returning a value when the MessageBox is closed. Even if you take
>> sys.exit() out and just print out the value the app returns, it will
>> still exit. Basically the whole app acts like a DialogBox that gets
>> triggered by the MessageBox.
>>
>> I'm not sure I fully understand what all the exec() function does.
> int QApplication.exec_() :
> Enters the main event loop and waits until exit() is called, then
> returns the value that was set to exit()
>
> QMessageBox.information() should call the inherited QDialog.exec_()
> which installs a local event loop, because the dialog is modal.
>
>
> I found out what's happening:
> Closing the QMessageBox is something like QDialog.done(). This emitts
> a QApplication.lastWindowClosed() signal if the dialog is the last
> window. Because of the default app.quitOnLastWindowClosed == True
> exit() will be called for the main loop and the application terminates
> regularly.
>
> So by adding app.setQuitOnLastWindowClosed(False) the application does
> not terminate any more.
>
> Tim
>
More information about the PyQt
mailing list