[PyQt] Integer rollover issue in signals

Rien Korstanje rien.korstanje at gmail.com
Mon Jun 7 23:30:35 BST 2010


Thanks Phil,

being able to use any Python type as signal arguments it's not quite what I
expected. I reckon the overlap with the C++ types had me confused then.

Regards,
Rien


On Mon, Jun 7, 2010 at 11:43 PM, Phil Thompson
<phil at riverbankcomputing.com>wrote:

> On Mon, 7 Jun 2010 11:47:40 +0200, Rien Korstanje
> <rien.korstanje at gmail.com>
> wrote:
> > Hello,
> >
> > I think I have identified an integer roll over issue when using PyQt
> slots.
> > When passing a python long through a signal it comes out as an int.
> Please
> > see the example below.
> >
> > Is this a bug?
>
> No. The problem is that int/long in Python is not the same as int/long in
> C++. The behaviour is chosen to work as expected most of the time, but you
> may hit problems when values start to overflow.
>
> > If so, is there a workaround?
>
> You need to specify a C++ type (ie. as a string) that is going to be big
> enough...
>
>    barSignal = pyqtSignal('unsigned long long')
>
> If you want to pass Python longs that won't fit into a C++ type then you
> will need to pass them as a Python object...
>
>    barSignal = pyqtSignal('PyQt_PyObject')
>
> ...but that means that you cannot connect to any C++ code that doesn't
> handle a PyQt_PyObject.
>
> Phil
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100608/900b26fb/attachment-0001.html>


More information about the PyQt mailing list