[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: PyQt6: Cannot create new custom QEvent
From: Phil Thompson <phil () riverbankcomputing ! com>
Date: 2021-04-19 13:30:39
Message-ID: c7b181905fb7ede446fc85a156cbf94d () riverbankcomputing ! com
[Download RAW message or body]
On 19/04/2021 14:15, Colin McPhail wrote:
> Hi,
>
>> On 19 Apr 2021, at 13:18, Ales Erjavec <ales.erjavec324@gmail.com>
>> wrote:
>>
>> 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).
>>
>
> I believe QEvent.registerEventType() returns an integer not a
> QEvent.Type instance. If you modify that line like:
> EventType = QEvent.Type(QEvent.registerEventType())
> then I think it might be accepted.
That will work but only because the value corresponds to MaxUser (Qt
allocates types from there working downwards). It won't work if you
register a second type (ie. MaxUser - 1) which does not have a
corresponding 'declared' value.
It will be fixed in the next snapshot.
Phil
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic