[Qt-interest] close app before exec()

RFOG no at mail.com
Thu Jul 2 11:51:22 CEST 2009


And you get a object semi constructed. What memory is assinged and what  
unassigned? Call destructor or not call? Etc.

I think no.

On Wed, 01 Jul 2009 21:38:01 +0200, Constantin Makshin  
<dinosaur-rus at users.sourceforge.net> wrote:

> Actually, exceptions are the best way to tell about an error in the  
> constructor. :)
>
> On Wed, 01 Jul 2009 13:08:20 +0400, RFOG <no at mail.com> wrote:
>> 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
========================================
La lectura es a la inteligencia lo que el ejercicio es al cuerpo.
		-- Richard Steele. (1672-1729) Escritor irlandés.



More information about the Qt-interest-old mailing list