[Qt-interest] Qt and exceptions

Anthony Serdyukov uksus70 at gmail.com
Wed Dec 10 14:40:24 CET 2008


You need to override notify() method of QCoreApplication, as far as i remember.

2008/12/10, Stephan Rose <kermos at somrek.net>:
> I'm having a problem with exception handling under Qt.
>
> I have a class called Exception which is thrown by my code whenever
> something bad enough happens to warrant throwing an exception. Generally
> this means a SQL query to the database failed when it shouldn't have.
>
> In main (simplified) then looks like this:
>
> int main(...)
> {
>   QApplication app(...);
>
>   // Some initial startup code
>   try
>   {
>     // Create main window
>     app.exec();
>   }
>   catch(Exception ex)
>   {
>     // Handle exception
>   }
> }
>
> Now if I throw an exception before app.exec() is called, it is correctly
> handled by my exception handler.
>
> However, any exception thrown while app.exec() is running results in only
> this message on the console:
>
> "terminate called after throwing an instance of 'Exception'"
>
> My Exception handler is never called. Does Qt have it's own exception
> handler and is it intercepting my exceptions? If so, how and where should I
> put my exception handler?
>
> Thanks,
>
> Stephan
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>


-- 
Regards,
Anthony



More information about the Qt-interest-old mailing list