Important: Please read the Qt Code of Conduct -

OSX Service and QApplication::macEventFilter()

  • Hello Folks;

    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:

    1. The QT application, "" is started. It has no UI to interact with.

    2. 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 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.

    3. 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, 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,

Log in to reply