[Qt-interest] Mac: Accessing filenames when started with "open -a"

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Thu Feb 10 18:44:21 CET 2011


On 2011-02-10 Christian Christian Lackas wrote:

> ...
> On Linux and Windows this works as expected, as does calling
>     /Application/MyApp/Contents/MacOS/MyApp file1.dcm file2.dcm ...
> Any input is highly appreciated.

"Think different": On Mac opening files works differently. Support for this has been added to Qt 4.x (I guess since 4.1), see

  http://doc.qt.nokia.com/qq/qq18-macfeatures.html#newevents
  http://doc.qt.nokia.com/4.7/qfileopenevent.html

Basically you register the file type in the Info.plist of your bundle and when the user clicks on such a document the OS sends a "File Open" event to your (running) app. If the app is not yet started, the OS will do so first. Like this is it guaranteed that if an instance of your application is already running no second instance is started.

Also note that this "File Open" event is really only supported on Mac, other OSs don't have this feature.

Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22





More information about the Qt-interest-old mailing list