[PyQt] Integer rollover issue in signals
Phil Thompson
phil at riverbankcomputing.com
Mon Jun 7 22:43:01 BST 2010
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
More information about the PyQt
mailing list