itom  3.0.0
main.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom.
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef MAIN_H
24 #define MAIN_H
25 
26 #include <qapplication.h>
27 #include <qdebug.h>
28 #include "opencv/cv.h"
29 
30 class QItomApplication : public QApplication
31 {
32  Q_OBJECT
33 public:
34 
35  QItomApplication ( int & argc, char ** argv ) : QApplication(argc,argv) {}
36 
37  bool notify ( QObject * receiver, QEvent * event )
38  {
39  try
40  {
41  return QApplication::notify(receiver,event);
42  }
43  catch (cv::Exception &exc)
44  {
45  qWarning("Itom-Application has caught a cv::exception");
46  qWarning() << (exc.err).c_str() << " from" << receiver->objectName();
47  //qDebug() << "Itom-Application caught an exception from" << receiver->objectName() << "from event type" << event->type();
48  qFatal("Exiting due to exception caught. OpenCV-Exception: %s", (exc.err).c_str());
49  }
50  catch(std::exception &exc)
51  {
52  qWarning("Itom-Application has caught an exception");
53  qWarning() << "Message:" << exc.what() << " from" << receiver->objectName();
54  qFatal("Exiting due to exception caught. Exception: %s", exc.what());
55  }
56  catch (...)
57  {
58  qWarning("Itom-Application has caught an exception");
59  qDebug() << "Itom-Application caught an exception from" << receiver->objectName() << "from event type" << event->type();
60  qFatal("Exiting due to exception caught");
61 
62  }
63  return false;
64  }
65 };
66 
67 #endif
Definition: main.h:30