C++ (Qt)bool MyApplication::notify ( QObject * o, QEvent * e ){ bool res = false; try { res = QApplication::notify(o, e); } catch(...) { QMessageBox::error(activeWindow(), tr("Error"), tr("Unhandled exception"), QMessageBox::Ok, QMessageBox::Ok); } return res;}
C++ (Qt)#include <QtGui/QApplication> protected: bool notify ( QObject * o, QEvent * e ); void closeEvent(QCloseEvent *event);//Событие закрытия окна
C++ (Qt)bool QApplication::notify ( QObject * o, QEvent * e )//bool KlenLibrary::notify ( QObject * o, QEvent * e )//Так даже не собирается{ bool res = false; try { res = QApplication::notify(o, e);//<---- Сегфолт :( } catch(...) { QMessageBox::critical(activeWindow(), tr("Error"), tr("Unhandled exception"), QMessageBox::Ok, QMessageBox::Ok); } return res;}
C++ (Qt)catch(...)
C++ (Qt)class Application : public QApplication{public: bool notify(QObject *receiver, QEvent *event) { // ... }} int main(/*ясно что*/){ Application app(argc, argv); // ... return app.exec();}
C++ (Qt)#ifndef KLENAPPLICATION_H#define KLENAPPLICATION_H #include <QApplication>#include <QtCore/QObject>#include <QtCore/QEvent>#include <QtGui/QMessageBox> class KlenApplication : public QApplication{public: KlenApplication(); bool notify ( QObject * o, QEvent * e );}; #endif // KLENAPPLICATION_H
C++ (Qt)#include "klenapplication.h" KlenApplication::KlenApplication(){} bool KlenApplication::notify ( QObject * o, QEvent * e ){ bool res = false; try { res = QApplication::notify(o, e); } catch(...) { QMessageBox::critical(activeWindow(), tr("Error"), tr("Unhandled exception"), QMessageBox::Ok, QMessageBox::Ok); } return res;}
C++ (Qt)int main(int argc, char *argv[]){ KlenApplication app(argc, argv);//<---ошибка if (argc > 1) {...
C++ (Qt)#ifndef qdoc QApplication(int &argc, char **argv, int = ApplicationFlags); QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags); QApplication(int &argc, char **argv, Type, int = ApplicationFlags);#if defined(Q_WS_X11) QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = ApplicationFlags); QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = ApplicationFlags);#endif#if defined(Q_OS_SYMBIAN) QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = ApplicationFlags);#endif#endif
C++ (Qt)KlenApplication(int &argc, char **argv) : QApplication(argc, argv) {}
C++ (Qt)#ifndef KLENAPPLICATION_H#define KLENAPPLICATION_H #include <QApplication>#include <QtCore/QObject>#include <QtCore/QEvent>#include <QtGui/QMessageBox> class KlenApplication : public QApplication{public: bool notify ( QObject * o, QEvent * e );}; #endif // KLENAPPLICATION_H #include "klenapplication.h" bool KlenApplication::notify ( QObject * o, QEvent * e ){ bool res = false; try { res = QApplication::notify(o, e); } catch(...) { QMessageBox::critical(activeWindow(), tr("Error"), tr("Unhandled exception"), QMessageBox::Ok, QMessageBox::Ok); } return res;} int main(int argc, char *argv[]){ KlenApplication app(); if (argc > 1) {
C++ (Qt)class KlenApplication : public QApplication{public: KlenApplication(int &argc, char **argv) : QApplication(argc, argv) {} bool notify ( QObject * o, QEvent * e ) { bool res = false; try { res = QApplication::notify(o, e); } catch(...) { QMessageBox::critical(activeWindow(), tr("Error"), tr("Unhandled exception"), QMessageBox::Ok, QMessageBox::Ok); } return res; }}; int main(int argc, char **argv){ KlenApplication app(argc, argv); ...}
C++ (Qt)uchar bvar;//bool bvar; try { ifile.read(reinterpret_cast<char*>(bvar), 10);//2, 100 bvar = 9999999999999;//Даже это проглотил istream >> bvar; istream >> bvar; istream >> bvar; istream >> bvar; istream >> bvar; istream >> bvar; istream >> bvar; istream >> bvar; istream >> bvar; istream >> bvar; istream >> bvar; istream >> bvar; istream >> bvar; istream >> bvar; // if (sappVersion != QCoreApplication::applicationVersion()) throw TError::WrongFileFormat(); } catch(TError::WrongFileFormat) { QMessageBox::warning(0, tr("Detection warning"), tr("Wrong file format!")); emit slotClose(); return 1; } catch(...) { QMessageBox::critical(0, tr("Detection error"), tr("An unknown error occurred!")); emit slotClose(); return 1; } istream >> sNameBook;