>From the documentation for QCoreApplication::exit: 

"After this
function has been called, the application leaves the main event loop and
returns from the call to exec(). The exec() function returns returnCode.
If the event loop is not running, this function does nothing."


QCoreApplication::quit Equivalent to calling
QCoreApplication::exit(0). Thus your call to a.quit() is doing nothing.


Therefore, there is nothing telling the event loop to stop once it
starts. 

Please NOTE: These commands stop the event loop return to the
caller. They do not immediately exit the application or the caller. So
if you move this call inside the event loop, you will need to return out
of the caller. 

Karl 

On 2013-07-26 14:17, Alexander Syvak wrote: 

>
So the a.exec() enters the event loop. Then the handler
showEvent(QEvent*) is executed. The std::runtime_error is thrown out of
the handler to the point of the previous call. 
> The exception is
caught inside the main() function. The dialog is thus not shown, but
start executing again. 
> 
> 2013/7/26 Constantin Makshin
<[email protected]>
> 
>> QCoreApplication::quit(), being an "alias" to
QCoreApplication::exit(0), does nothing outside an event loop which in
your case is started afterwards. 
>> 
>> On Jul 26, 2013 10:20 PM,
"Alexander Syvak" <[email protected]> wrote: 
>> 
>>> Hello, after
calling w.show() there's method redefined void
event_dlg::showEvent(QShowEvent *). In this method there's an exception
thrown. The process does not terminate. 
>>> Can anyone througly explain
why is the job running after calling either close() of the only one and
thus the last window (event_dlg w) or quit() of the QApplication a?
>>>

>>> #include "event_dlg.h" 
>>> 
>>> #include <QApplication>
>>> 
>>>
#include <QMessageBox>
>>> 
>>> #include <QDebug>
>>> 
>>> int main(int
argc, char *argv[])
>>> 
>>> {
>>> 
>>> QApplication a(argc, argv);
>>>

>>> event_dlg w;
>>> 
>>> try
>>> 
>>> {
>>> 
>>>
w.set_config_file("./events.xml");
>>> 
>>> w.show();
>>> 
>>> }
>>>

>>> catch ( std::runtime_error & e )
>>> 
>>> {
>>> 
>>> // QMessageBox
msgBox;
>>> 
>>> // msgBox.setText(e.what());
>>> 
>>> //
msgBox.exec();
>>> 
>>> // qDebug() << w.close();
>>> 
>>> a.quit();
>>>

>>> }
>>> 
>>> return a.exec();
>>> 
>>> }
>>> 
>>>
_______________________________________________
>>> Interest mailing
list
>>> [email protected]
>>>
http://lists.qt-project.org/mailman/listinfo/interest [1]
>> 
>>
_______________________________________________
>> Interest mailing
list
>> [email protected]
>>
http://lists.qt-project.org/mailman/listinfo/interest [1]
> 
>
_______________________________________________
> Interest mailing
list
> [email protected]
>
http://lists.qt-project.org/mailman/listinfo/interest [1]




Links:
------
[1]
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to