Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, December 2007
Getting notified when OS shutdown


Message 1 in thread

Hello,
I have a little problem. I wrote a application with a few threads 
inside. The application should get notified, when anyone shuts down (in 
this case windows). QT has CloseEvent and aboutToQuit envents/Slots. My 
problem is, that when Windows shuts down, always CloseEvent is called. I 
overwrote it, so I receive the event. The problem is now, that I cannot 
decide, where the event comes from, from a shutdown or from a click on 
the "Dialog X" in the right upper corner of the dialog. Next problem is, 
that I check here, if anyone clicks the X, I bring the application into 
system tray when the threads are running, instead of closing it.
I tried this: (from the documentation)
"bool QEvent::spontaneous () const"
Returns true if the event originated outside the application (a system 
event); otherwise returns false.
but this function always return true when one clicks on the "X".

Any idea, how I can filter the shutdown event to make a clean close ?

Regards,
Peter

--
 [ signature omitted ] 

Message 2 in thread

From: peter [mailto:qt@xxxxxxxxxxxxx] 
> [...]. The application should get notified, when anyone 
> shuts down (in this case windows). QT has CloseEvent
> and aboutToQuit envents/Slots. My problem is, that
> when Windows shuts down, always CloseEvent is called. [...]
> 
> Any idea, how I can filter the shutdown event to make a clean close ?
> [...]

Maybe QSessionManager and QApplication::commitData() works for you?

Best Regards / Mit freundlichen Grüßen
Rainer Wiesenfarth

-- 
 [ signature omitted ] 

Attachment: smime.p7s
Description: S/MIME cryptographic signature


Message 3 in thread

Rainer Wiesenfarth schrieb:
> From: peter [mailto:qt@xxxxxxxxxxxxx] 
>> [...]. The application should get notified, when anyone 
>> shuts down (in this case windows). QT has CloseEvent
>> and aboutToQuit envents/Slots. My problem is, that
>> when Windows shuts down, always CloseEvent is called. [...]
>>
>> Any idea, how I can filter the shutdown event to make a clean close ?
>> [...]
> 
> Maybe QSessionManager and QApplication::commitData() works for you?
> 
> Best Regards / Mit freundlichen Grüßen
> Rainer Wiesenfarth
> 
Hello Rainer,
thank you for your info, I'll try that.

Regards,
Peter

P.S Schöne Weihnachten und einen guten Rutsch in's neue Jahr.

--
 [ signature omitted ]