[PyQt] Issue with pyqtSignal
Phil Thompson
phil at riverbankcomputing.com
Sat Nov 5 13:48:13 GMT 2011
On Sat, 5 Nov 2011 10:05:45 +0100, Detlev Offenbach
<detlev at die-offenbachs.de> wrote:
> Am 04.11.2011 um 18:04 schrieb Phil Thompson:
>
>> On Fri, 4 Nov 2011 11:23:07 +0100, Detlev Offenbach
>> <detlev at die-offenbachs.de> wrote:
>>> Hello,
>>>
>>> I am defining a signal in one of my classes like this.
>>>
>>> tabRelocateRequested = pyqtSignal(int, int, int)
>>>
>>> When this signal is emitted, the first parameter is bigger than an int
>>> (e.g. by using id()). This causes the signal receiver to get a first
>>> parameter, that is different to the value given in the emit call. How
>> can I
>>> correct my code (code i within eric4/5).
>>
>> Use long instead of int?
>
> Python3 (forgot to mention that) doesn't know about long anymore. Maybe
> the pyqtSignal code should work with long instead of int?
The current behaviour is intentional as I considered this to be the least
surprising when using a signal defined in Python in C++ code. Thinking
about it now this is probably a very minor use case.
At the moment a Python v2 int (actually implemented as a C++ long), a
Python v2 long and a Python v3 int are all mapped to a C++ int.
Maybe a better mapping should be Python v2 int to a C++ long, and a Python
v2 long and a Python v3 int to a C++ long long. However it would still be
possible to lose data for very big values - the only way to avoid that
would be to pass the Python object itself which would make it impossible to
reuse the class defining the signal from C++ code.
As a work around you can always specify the C++ type as a string, eg.
"long long".
Thoughts?
Phil
More information about the PyQt
mailing list