[PyQt] QDesktopServices.setUrlHandler not called on OS X

Marko Luther marko.luther at gmx.net
Sun Jul 7 13:14:21 BST 2019


Dear Florian,

thanks for this clarification. That connection between QDesktopServices.setUrlHandler and the QDesktopServices.openUrl escaped my eye. I will use the IPC mechanism to resolve this.

Thanks!
Marko

> On 7. Jul 2019, at 13:35, Florian Bruhin <me at the-compiler.org> wrote:
> 
> 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/



More information about the PyQt mailing list