NOTE, the "URL Protocol" key really is empty. It's simply a place marker

NOTE, the extra quotes around the %1 are essential especially if your URL contains commas, spaces or any other character that specifies a parameter separator on the command line.

Operation

When the user accesses a link with like "anewscheme:datagoeshere" the application is executed and the link itself is sent to the application as argv[1]. It's that simple. You may want to make your application single instance and pipe the given URL to the first instance of the application.

Mac Os X

For the Mac we have much more work to do. The first thing we will need to do is to install an AppleEvent handler in our "main" function like this...

NOTE:"app" is whatever you want. Possibly the most convenient object to pass to the event handler is your QApplication derived application class.

We're NEARLY there! The very last thing we need to do is to invoke the Carbon event loop. However, Qt does this for you when you create a QApplication object (which you did in main just after setting up the Apple event handler right?)

To make this all compile and link properly we need to link against the Carbon framework. TO do this we need to add one extra line to our qmake .pro file when building for the Mac

mac:LIBS += -framework Carbon

To finish off we need to add some XML to Info.plist which is inside the app bundle. Use finder to open the package and in the "Contents" folder you'll find "Info.plist" - you can use the property edit to edit this - just double click.

However! There's a little trick you can use in your qmake .pro (or .pri) file. Qt installs a very minimal Info.plist in your app bundle. To override this and provide your own add the line

mac:QMAKE_INFO_PLIST = ./Info.plist

Another way to do this is to use "install" type "man install" for more info. This lets you add/delete files from a package at will and is very powerful.