Where am I supposed to reimplement QApplication::notify function? What I mean is, which class? One of my own classes or subclass some of Qt's class and do it there? I need this because I'm getting the following error while downloading file from a server(small files are downloaded ok, but large ones cause this msg):
Qt has caught an exception thrown from an event handler. Throwing exceptions from an event handler is not supported in Qt. You must reimplement QApplication::notify() and catch all exceptions there.
Just subclass QApplication
and in your notify(..)
method do something like this:
try {
return QApplication::notify( receiver, event );
} catch ( std::exception& e ) {
showAngryDialog( e );
return false;
}
Then use it in your main function instead of QApplication
.
As said before create you own application object that inherits from QtApplication and redefine 'notify'. It is the way to go. However be very sure to use this constructor:
MyApplication::MyApplication(int &argc, char *argv[]);
Setting argc as reference with '&' is important as it avoids a crash on some platforms.
The full procedure is described here: http://qt-project.org/forums/viewthread/17731
My own implementation:
class MyApplication : public QApplication
{
public:
MyApplication(int &argc, char ** argv);
// ~MyApplication();
private:
bool notify(QObject *receiver_, QEvent *event_);
};
(The crash described above happened on Ubuntu 13.10 64bits but was not present on version 12.04 64 bits.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With