Qt6: QUrl and UrlFormattingOption vs. ComponentFormattingOption

Florian Bruhin me at the-compiler.org
Thu Aug 26 16:34:27 BST 2021


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

-- 
            me at the-compiler.org | https://www.qutebrowser.org 
       https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
       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/20210826/b677e8a8/attachment.sig>


More information about the PyQt mailing list