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

Phil Thompson phil at riverbankcomputing.co.uk
Thu Feb 17 09:10:20 GMT 2005


In fact the exception message is "correct". When there are overloaded
functions or ctors, none of which have a matching signature, then there is
a (potentially) different exception message for each one. SIP then has to
choose the most appropriate one. It's impossible to get this right
(without reading the programmer's mind), so it chooses the one related to
the signature that had the highest number of successfully parsed
arguments.

In this case this was the 3rd ctor, which only required a single integer
argument.

BTW, your code could be changed to use that 3rd ctor and make a separate
call to setData(). That would make it portable to SIP 4.2 and earlier
versions. The final SIP 4.2 will include sip.SIP_VERSION to allow code to
check dynamically if it really needs to.

Phil

> Thanks, that clears it up. The exception message was misleading.
>
> -Selim
>
> Selim Tuvi, Research Engineering Group, SLAC
> GLAST, I&T Online, MS 98
> Tel:650-926-3376 Fax:650-926-4335
>
>
>> -----Original Message-----
>> From: Phil Thompson [mailto:phil at riverbankcomputing.co.uk]
>> Sent: Wednesday, February 16, 2005 1:45 AM
>> To: Tuvi, Selim
>> Cc: pykde at mats.imk.fraunhofer.de
>> Subject: Re: QCustomEvent::QCustomEvent ( Type type, void * data )
>> constructor no longer supported?
>>
>> > 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.
>>
>> Phil
>
>





More information about the PyQt mailing list