[Interest] Triggering Actions on Application Close

Gopalakrishna Bhat gopalakbhat at gmail.com
Tue Jul 9 06:12:25 CEST 2013


On Tue, Jul 9, 2013 at 9:33 AM, andy fillebrown
<andy.fillebrown at gmail.com>wrote:

> I think the problem might be the use of the "Force quit" button.  That is
> not a normal way to close an application.  Pressing the "Force quit" button
> is similar to using the OS to kill the process. I'd be surprised if any
> slots were called in that case.  Try closing the application like a normal
> user would.
>
> Cheers,
> ~ andy.f
>
>
>
>
>
> On Mon, Jul 8, 2013 at 9:11 PM, Syam Krishnan <syamcr at gmail.com> wrote:
>
>> On 07/09/2013 04:03 AM, Mitchell Verter wrote:
>> > How do I trigger cleanup actions on application close?
>> >
>> > I need to write out temporary objects and a footer to a file whenever
>> > the Application is closed.
>> >
>> > I've tried several approaches, but none of them produces any result
>> > when I "Force Quit" by hitting the red button within QtCreator.
>>
>
As others have pointed out, forcing an application to quit is killing the
process immediately. All the events in the event queue will discarded.
Hence none of your event handlers will be called.

Try doing normal application termination like pressing the Close button on
the window etc.

> >
>> > More specifically, I have tried to connect:
>> >
>> >      QObject::connect(&myApplication, SIGNAL(aboutToQuit()),
>> > &myMainWindow,  SLOT(closeFileSlot()));
>> >
>> > (note that I am using a QApplication rather than a QCoreApplication --
>> > I'm not sure if it makes a difference)
>>
>>
>> You could try the signal QApplication::lastWindowClosed() or override
>> the closeEvent() function of your QMainWindow class.
>>
>> regards,
>>
>> Syam
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>


-- 
My blog http://gkbhat.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130709/4d9a8804/attachment.html>


More information about the Interest mailing list