[Qt-interest] close app before exec()
RFOG
no at mail.com
Wed Jul 1 11:08:20 CEST 2009
Or better than that: throw an exception in ctor and catch in main...
I know is not a good idea fire an exception in a ctor, but if you are
going to exit...
On Wed, 01 Jul 2009 11:04:40 +0200, RFOG <no at mail.com> wrote:
> Modfiy the ctor to receive a boolean by reference and the do something
> like this:
>
> bool bExit;
> MainWindow w(bExit); <--- Here I check for conditions...
> if(!bExit)
> {
> w.show();
> return a.exec();
> }
>
> MainWindows ctor signature coud be:
>
> MainWindow(bool& bexit)
> {
> ...
> }
>
> I do not know if it will work with QT, but seems a common scenario.
> However you cannot bye sayng nothing to the user...
>
> On Wed, 01 Jul 2009 10:57:31 +0200, OS Prog <osprog at gmail.com> wrote:
>
>> Hi,
>>
>> I have QMainWindow application. In the QMainWindow constructor I check
>> for
>> conditions and if they are not met I want to exit from the application.
>> The
>> close(), QApplication::exit(), and so on doesn't work, because they are
>> before application.exec().
>>
>> In main.cpp I have
>> ...
>> MainWindow w; <--- Here I check for conditions...
>>
>> w.show();
>>
>> return a.exec();
>>
>> ...
>>
>> Regards,
>> Nikolay
>
>
>
--
Microsoft Visual C++ MVP => http://geeks.ms/blogs/rfog
========================================
Es muy grave el olvido de la historia o su deformación, porque la realidad
siempre se venga del que no cuenta con ella.
-- Julián Marías. (1914).
More information about the Qt-interest-old
mailing list