[Qt-interest] Exiting before the main event loop

Scott Aron Bloom Scott.Bloom at sabgroup.com
Mon Feb 23 04:40:42 CET 2009


 -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Pete Black
> Sent: Sunday, February 22, 2009 6:57 PM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Exiting before the main event loop
> 
> Rohan McGovern wrote:
> > On Monday 23 February 2009, ext Pete Black wrote:
> >> Hi,
> >>
> >> Anyone know a good way of exiting an application before the main
> >> event loop has been entered? That is before app.exec() has been
> >> called, but withing the app object itself.
> >
> > Hi,
> >
> > Just don't call app.exec() if you don't want to execute the
> > application.
> >
> 
> Yeah, was hoping there was a way, but I probably have to do that.
Which
> means refactoring. Boxed myself in a bit by parsing some command line
> parameters from the app's constructor and I need to be able to quit
from
> there.
> 
> Thanks,
> Pete

If you are using the loop for a reason, ie you have multiple threads
with sigs & slots needing the loop for their execution, or events going
on...  Then simply call qApp->quit or connect a singal to it, since quit
is a slot.

BTW.. that's essentially how a windowed based env works, a window
manager keeps track of all windows and when the last one is closed, a
signal is emmited that is connected to quit.

BTW.. if your not using a GUI, use QCoreApplication

Scott




More information about the Qt-interest-old mailing list