Solved QFileOpenEvent
-
hi
i want open a file, double clicking on an file in the Finder on OS X
in mac 'QApplication::arguments()' don't work!
i need a good example for QFileOpenEvent -
Hi,
Because as the name suggests it's an event. The file name is not added to the argument list. First thing, did you configure your application to handle files opened that way ?
-
@SGaist hi
how to configure application to handle files?
i add some suffix like .png to Info.plist in app/Contents, this is configure application? -
Please share your .plist file
-
@SGaist this is my Info.plist
-
That looks OK. You should have the event sent to your application if you e.g. drop a supported file on the Dock Icon of your application.
-
@SGaist What event?
Please show me an example -
QFileOpenEvent.
class MyApplication : public QApplication { public: MyApplication(int &argc, char **argv, int flags = ApplicationFlags) : QApplication(argc, argv, flags) { } bool event(QEvent *event) { if (event->type() == QEvent::FileOpen) { QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event); qDebug() << "File open" << openEvent->file(); } return QApplication::event(event); } };
Use it in place of QApplication.