[Qt-interest] try-catch in QApplication::notify() reimplementation

Eirik Ulvik eiriku at simsurgery.com
Thu Aug 5 15:48:34 CEST 2010



Den 05.08.2010 15:18, skrev Karl Krach:
> 
> Hello,
> 
> I have a short question. I'm just wondering, how "You must reimplement
> QApplication::notify() and catch all exceptions there." could work.
> 
> I ve implemented the following, and many mailinglist posts recommend the same,
> but it's not working:
> 
> class MyApplication : public QApplication
> {
> public:
>     MyApplication(int argc, char** argv) : QApplication(argc, argv) {}
>     virtual ~MyApplication() {}
>     virtual bool nofity(QObject *rec, QEvent *ev)
>     {
>         qDebug() << "MyApplication::nofity";
>         try {
>             return QApplication::notify(rec, ev);
>         }
>         catch( ... ) {
>             qDebug() << "Unknown Exception: Terminating!";
>             exit(0);
>         }
>         return false;
>     }
> };

Just ruling out the obvious, do you instantiate a MyApplication object
instead of a QApplication object in your main function? I have the same
setup as you and it works without problems.

Eirik

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100805/847f6da7/attachment.bin 


More information about the Qt-interest-old mailing list