Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
OSX Service and QApplication::macEventFilter()
SquimbellyToes last edited by
I'm relatively new to QT and am developing a QT application for OSX that I wish to respond to a custom service invoked on a file. However, I'm not clear on how to implement this and would be very grateful for any knowledge or advice you might be able to offer.
Here's an example of what I need to accomplish:
The QT application, "MyApplication.app" is started. It has no UI to interact with.
The user right-clicks on a file somewhere on the file system. For sake of this example, let's say it's /Users/Bob/Desktop/MyGroceryList.txt.
On the context menu they see a custom Service (that lives in /System/Library/Services), that will notify MyApplication.app of an operation to perform on /Users/Bob/Desktop/MyGroceryList.txt. A good example of the type of action to be performed would be adding the path of /Users/Bob/Desktop/MyGroceryList.txt to an XML file.
MyApplication.app is notified of the request, via the Service, performs the requested operation, and notifies the user that the operation has completed.
I've looked at the d-bus implementation included with QT, but including d-bus with my custom application is not straight-forward - my target users will not be amenable to compiling and installing it.
I see that QApplication::macEventFilter() may offer some hope (please see http://portal.nersc.gov/svn/visit/trunk/src/gui/QvisApplication.C), but I'm not clear on how one would raise an event to be consumed on the invocation of my custom Service.
Might anyone have some advice on how I might proceed?
Thank you very much,