PDA

View Full Version : QApplication::notify reimplementation



sa5webber
31st August 2012, 00:00
I know this is obviously not a new question but so far I have not been able to get it to work. So here is my code. It compiles but when I run it and execute a throw() within my MainWindow class, the throw() seems to get caught by the reimplemented notify, but the notify method seems to keep getting called over and over again until I eventually get a SIGABRT. What am I doing wrong?



#include <QtGui/QApplication>
#include "mainwindow.h"

class App : public QApplication
{
public:

App(int& argc, char** argv):QApplication(argc,argv){}
virtual ~App(){}

virtual bool notify(QObject *receiver, QEvent *event)
{
try
{
return QApplication::notify(receiver, event);
}
catch(std::exception& e)
{
QMessageBox::information(0,"","Exception thrown",QMessageBox::Ok);
}
return false;
}
};

int main(int argc, char *argv[])
{
App a(argc, argv);
MainWindow w;

w.show();
return a.exec();
}