Advertisement
adriweb

url protocol handler

Feb 17th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifndef MYAPPLICATION_H
  2. #define MYAPPLICATION_H
  3.  
  4. #include <QApplication>
  5. #include <QFileOpenEvent>
  6. #include <QEvent>
  7. #include <QDebug>
  8.  
  9. class MyApplication : public QApplication
  10. {
  11.     Q_OBJECT
  12.  
  13. public:
  14.     MyApplication(int& argc, char **argv) : QApplication(argc, argv)
  15.     {}
  16.  
  17. protected:
  18.     bool event(QEvent* event)
  19.     {
  20.         if (event->type() == QEvent::FileOpen)
  21.         {
  22.             QString url = static_cast<QFileOpenEvent*>(event)->url().toString();
  23.             url.replace("tiplanet://", "");
  24.             QStringList pieces = url.split("/");
  25.  
  26.             qDebug() << "split: " << pieces << endl;
  27.  
  28.             return true;
  29.         }
  30.         return QApplication::event(event);
  31.     }
  32.  
  33. };
  34.  
  35. #endif // MYAPPLICATION_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement