I have to subclass QApplication and redefine event function, that waiting for FileOpen event and runs some actions after it comes, and also i created template Info.plist file with extensions of registred filetypes for this application. When i try to open associated file by double mouse click, application have to start and creates main window, but then it crash in QCoreApplication::Arguments and message box from Application::event not executed.

Qt Code:
  1. class Application : QApplication
  2. {
  3. public:
  4. Application( int argc, char * argv[]):QApplication(argc,argv){}
  5. protected:
  6. virtual bool event(QEvent * event )
  7. {
  8. if( event->type() == QEvent::FileOpen )
  9. {
  10. box.setText(static_cast<QFileOpenEvent>(event)->file());
  11. box.exec();
  12. return true;
  13. }
  14. return false;
  15. }
  16.  
  17. }
To copy to clipboard, switch view to plain text mode 

But if i create messagebox before event type check(as in code below), it works fine, both messagebox are showing. What could be the the reason for this behavior ?

Qt Code:
  1. class Application : QApplication
  2. {
  3. public:
  4. Application( int argc, char * argv[]):QApplication(argc,argv){}
  5. protected:
  6. virtual bool event(QEvent * event )
  7. {
  8. QMessageBox msgbox;
  9. msgbox.setText(QString::number(event->type()));
  10. msgbox.exec()
  11. if( event->type() == QEvent::FileOpen )
  12. {
  13. box.setText(static_cast<QFileOpenEvent>(event)->file());
  14. box.exec();
  15. return true;
  16. }
  17. return false;
  18. }
  19.  
  20. }
To copy to clipboard, switch view to plain text mode