Hi,
There is no way to catch all errors an app can cause... for example, an
try{
int a=10/0;
catch(...){}
try{
int a=10/0;
catch(...){}
To copy to clipboard, switch view to plain text mode
will close the program without entering the catch block.
However, you may be interested in something like csignal.h (http://www.cplusplus.com/reference/clibrary/csignal/) that can catch many signals from system, then handle them, creating a new QWidget and doing a QApplication::exec()...
for example, in your main.cpp:
#include <all yout include files>
#include <signal.h>
void catchError(int b){
qDebug()<<"Got error #: "<<b;
throw "Some Error here";
}
int main(int argc, char *argv[])
{
signal(SIGSEGV, catchError);
try{ // here, the default behaviour
MyMainWindow w;
w.show();
a.exec();
}catch(...){ // here, after a SegFault...
QWidget b;
//start here your Widget that will show the error... b.show();
a.exec(); // Event loop again :)
}
return 0; // it is interesting to control with an int ret here...
}
#include <all yout include files>
#include <signal.h>
void catchError(int b){
qDebug()<<"Got error #: "<<b;
throw "Some Error here";
}
int main(int argc, char *argv[])
{
signal(SIGSEGV, catchError);
try{ // here, the default behaviour
QApplication a(argc, argv);
MyMainWindow w;
w.show();
a.exec();
}catch(...){ // here, after a SegFault...
QApplication a(argc, argv);
QWidget b; //start here your Widget that will show the error...
b.show();
a.exec(); // Event loop again :)
}
return 0; // it is interesting to control with an int ret here...
}
To copy to clipboard, switch view to plain text mode
The signal() will "connect" (not in QT way) that function with the error... The function will be called exactly where the error has occurred, so we need to throw something to enforce we will exit the first event loop.
After that, we can open a new widget and start a second event loop... 
HTH.
Bookmarks