[PyQt] QDesktopServices.setUrlHandler not called on OS X

Florian Bruhin me at the-compiler.org
Sun Jul 7 12:35:53 BST 2019


Hi,

On Sun, Jul 07, 2019 at 01:12:22PM +0200, Marko Luther wrote:
> Now it seems to me that the 
> 
> > QDesktopServices.setUrlHandler
> 
> is doing nothing, at least on Mac OS X and Windows.
> 
> Windows seems not to be able to send even the event to an already running
> instance of the app that got registered via the corresponding registry
> entries. Instead it starts a new instance of the app and hands the URL over
> via sys.args. Strange.
> 
> Is nobody using URL schemes?

QDesktopServices.setUrlHandler probably doesn't do what you think it does. It
only affects URLs opened via QDesktopServices.openUrl in Qt.

From its docs:

    This function provides a way to customize the behavior of openUrl(). If
    openUrl() is called with a URL with the specified scheme then the given method
    on the receiver object is called instead of QDesktopServices launching an
    external application.

It does talk about recieving data from other apps after that, but that seems to
be iOS-specific.

At least for macOS, you'll need to mention the scheme in your Info.plist and
get an OpenEvent with that URL. On Windows, indeed you get the URL as an
argument. What applications do typically is communicating with the existing
instance via IPC and then quitting the new instance.

Florian

-- 
https://www.qutebrowser.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
         I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190707/ca57ff29/attachment.sig>


More information about the PyQt mailing list