Qt6: QUrl and UrlFormattingOption vs. ComponentFormattingOption

Phil Thompson phil at riverbankcomputing.com
Thu Aug 26 17:19:57 BST 2021


On 26/08/2021 16:34, Florian Bruhin wrote:
> Hi,
> 
> Qt's QUrl.toString() (and other methods taking 
> QUrl.UrlFormattingOption)
> are a bit weird, because they *also* can take
> QUrl.ComponentFormattingOption:
> https://doc.qt.io/qt-6/qurl.html#UrlFormattingOption-enum
> 
> However, combining the two doesn't seem to be possible anymore with 
> PyQt6:
> 
>     >>> from PyQt6.QtCore import QUrl
>     >>>
> QUrl("https://example.org").toString(QUrl.UrlFormattingOption.RemovePassword
> | QUrl.ComponentFormattingOption.FullyEncoded)
>     Traceback (most recent call last):
>       File "<stdin>", line 1, in <module>
>     TypeError: unsupported operand type(s) for |:
> 'UrlFormattingOption' and 'ComponentFormattingOption'
> 
> and converting won't work either:
> 
>     >>>
> QUrl("https://example.org").toString(QUrl.UrlFormattingOption.RemovePassword
> |
> QUrl.UrlFormattingOption(QUrl.ComponentFormattingOption.FullyEncoded))
>     ValueError: <ComponentFormattingOption.FullyEncoded: 32505856> is
> not a valid QUrl.UrlFormattingOption
> 
> Florian

Fixed in the next PyQt6 snapshot.

Thanks,
Phil


More information about the PyQt mailing list