[PyKDE] Re: QCustomEvent::QCustomEvent ( Type type, void * data ) constructor no longer supported?

Phil Thompson phil at riverbankcomputing.co.uk
Wed Feb 16 09:45:15 GMT 2005

> The following code which used to work with PyQt 3.13 does not work with
> PyQt-commercial-snapshot-20050211:
> class PorcineEvent(qt.QCustomEvent):
>     StatusChangeType=qt.QEvent.User+10
>     CommandingChangeType=qt.QEvent.User+11
>     def __init__(self,type,data):
>         qt.QCustomEvent.__init__(self,type,data)
> Traceback (most recent call last):
>   File "c:\projects\LATTE\tools\taskEngine.py", line 74, in run
>     taskArgsKwargs[0](*taskArgsKwargs[1:-1], **taskArgsKwargs[-1])
>   File "c:\projects\LATTE\power\PorcinePanel.py", line 272, in __getStatus
>     qt.QApplication.postEvent(self,PorcineEvent(PorcineEvent.StatusChangeType,st
> atus))
>   File "c:\projects\LATTE\power\PorcinePanel.py", line 400, in __init__
>     qt.QCustomEvent.__init__(self,type,data)
> TypeError: too many arguments to QCustomEvent(), 1 at most expected

In SIP 4.2 enums are implemented as distinct types rather than integers so
that they nehave the same as they do in C++. After doing the addition, the
type of the above expression is integer, but it should be Type. Replace it
with, something like, the following.

    StatusChangeType = qt.QEvent.Type(qt.QEvent.User + 10)

The exception message looks wrong - I will check that.


More information about the PyQt mailing list