[Interest] Triggering Actions on Application Close
Charles Yin
charles at mazymind.com
Tue Jul 9 06:13:56 CEST 2013
see also :
http://stackoverflow.com/questions/3360761/how-to-do-a-cleanup-after-sigkill
2013/7/9 Gopalakrishna Bhat <gopalakbhat at gmail.com>
>
>
>
> 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
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
--
--
Yunqiao (Charles) Yin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130709/aab73e29/attachment.html>
More information about the Interest
mailing list