PyQt 6.2 / Qt 6.3: ValueError for new enum members

Florian Bruhin me at the-compiler.org
Sat Apr 23 10:22:28 BST 2022


Hi,

With the attached example script, I see:

    Qt 6.2.3, PyQt 6.2.3, qVersion 6.3.0

    PixelMetric.PM_DefaultFrameWidth
    PixelMetric.PM_DefaultFrameWidth
    PixelMetric.PM_LineEditIconSize

    Traceback (most recent call last):
      File "/usr/lib/python3.10/enum.py", line 385, in __call__
        return cls.__new__(cls, value)
      File "/usr/lib/python3.10/enum.py", line 710, in __new__
        raise ve_exc
    ValueError: 94 is not a valid QStyle.PixelMetric

But I've never created a QStyle.PixelMetric myself - I just passed what
I got from PyQt back into PyQt!

I believe this is related to my mixture of versions (which I think was
supported so far, correct?), and the fact that this enum member was
added in Qt 6.3: https://codereview.qt-project.org/c/qt/qtbase/+/363114

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 --------------
from PyQt6.QtCore import QT_VERSION_STR, PYQT_VERSION_STR, qVersion
from PyQt6.QtWidgets import QApplication, QCommonStyle, QStyle, QStyleFactory, QLineEdit


class Style(QCommonStyle):

    def __init__(self, parent=None):
        super().__init__()
        self._style = QStyleFactory.create("Fusion")

    def pixelMetric(self, metric, option=None, widget=None):
        print(metric)
        return self._style.pixelMetric(metric, option, widget)


print(f"Qt {QT_VERSION_STR}, PyQt {PYQT_VERSION_STR}, qVersion {qVersion()}")


app = QApplication([])
style = Style()

le = QLineEdit()
le.setStyle(style)
le.setClearButtonEnabled(True)
le.show()

app.exec()
-------------- 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/20220423/ad5139da/attachment.sig>


More information about the PyQt mailing list