[PyQt] After MessageBox app quits...why?

Demosthenes Koptsis demosthenesk at gmail.com
Thu Oct 27 22:00:41 BST 2016


Yes, David i found it a bit later...

Thanks for your reply

Regards

Dim


On 10/27/2016 11:41 PM, David Boddie wrote:
> On Thu Oct 27 18:20:05 BST 2016, Demosthenes Koptsis wrote:
>
>> Hello, i have a PyQT systray app with a menu and two actions.
>>
>> Action1 is Exit and action2 display a MessageBox with Hello World message.
>>
>> When i click OK to MessageBox app quits...why?
> It's due to an obscure feature of QApplication that, by default, exits the
> application when the last window is closed. You can turn it off in your
> program by calling
>
>    app.setQuitOnLastWindowClosed(False)
>
> after you create the QApplication instance.
>
> The feature was introduced to prevent certain kinds of applications from
> lurking in the background after all their windows had been closed. In your
> case, you create a window but never open it, so I expect QApplication just
> treats the message box as the only window that the application uses.
>
> David
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt



More information about the PyQt mailing list