Results 1 to 3 of 3

Thread: File association in mac os x

  1. #1
    Join Date
    Jan 2010
    Posts
    95
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default File association in mac os x

    Hi All,

    Can you detail me the steps for file association for deploying a Qt app on mac os x?

    Regards,
    volcano

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: File association in mac os x

    I'm not aware of a Qt class that provides this functionality. To my knowledge this is done in an OS specific method. Start with the link below for the section on OSX and also google for more information:

    https://en.wikipedia.org/wiki/File_association
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  3. #3
    Join Date
    May 2017
    Posts
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: File association in mac os x

    I poked around in the sources a bit, and here's what I found:

    1. Given macOS looks for file associations in the application's Info.plist, you'll have to set up your app's with the proper CFBundleDocumentTypes keys. You also have to set your QMAKE_INFO_PLIST key to point to that Info.plist file
    2. Qt's Mac code has a QCocoaIntegration object, which creates a QCocoaApplicationDelegate and provides that to macOS as the application delegate.
    3. If your cocoa application already has a delegate set, QCocoaIntegration will replace it with its delegate and install it in the QCocoaApplicationDelegate as the "reflectionDelegate", to which it forwards, among others, the -applicationpenFiles: delegate method.
    4. So, to handle file open requests, create an Objective-C NSObject subclass that conforms to the NSApplicationDelegate protocol and implements -applicationpenFiles: just like any other Mac application would do, and install it into [NSApplication sharedApplication] as the delegate.
    5. From that object, call out to your Qt code and do whatever you want to do in response to a file being opened.

    Note: I've only read the Qt sources so far, I have yet to actually try this out. You may have to make sure you get your delegate in before QCocoaIntegration installs its delegate.

  4. The following user says thank you to uliwitness for this useful post:

    volcano (28th September 2017)

Similar Threads

  1. File Association Icon
    By parshant65@gmail.com in forum Qt Programming
    Replies: 1
    Last Post: 6th March 2014, 15:22
  2. System File Association
    By johnmauer in forum Qt Programming
    Replies: 5
    Last Post: 10th November 2010, 22:35
  3. QwtPlot sample to pixel association
    By catto in forum Qwt
    Replies: 4
    Last Post: 9th October 2010, 19:57
  4. Replies: 3
    Last Post: 29th October 2009, 17:52
  5. association between 2 classes
    By castorvert in forum General Programming
    Replies: 4
    Last Post: 5th April 2006, 07:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.