PyQt6: Cannot create new custom QEvent

Ales Erjavec ales.erjavec324 at gmail.com
Mon Apr 19 13:18:58 BST 2021


Hi,

In PyQt6 this fails with a type error:
```
from PyQt6.QtCore import QEvent

class CustomEvent(QEvent):
    EventType = QEvent.registerEventType()
    def __init__(self):
        super().__init__(CustomEvent.EventType)  # << Error Here

ev = CustomEvent()
ev.type()
```
because the QEvent.__init__ arg must be QEvent.Type; in PyQt6 this is
an python enum and cannot represent 'undeclared' values).

Best wishes
Aleš Erjavec


More information about the PyQt mailing list