Hello,<br><br>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. <br><br>Is this a bug? If so, is there a workaround?<br>
<br>Regards,<br>Rien Korstanje<br><br>---<br><br>'''<br>Demonstrates an integer overflow in pyqt signals with <br>Python 2.6.5 and PyQt-Py2.6-gpl-4.7.3-2.<br><br>When the button is pressed, a signal is emitted with as argument <br>
maxint + 1. Yet the slot receiving this signal gets minint. <br><br>Expected output:<br><br>Value that goes in 2147483648<br>Value that comes out -2147483648<br><br>Created on 7 Jun 2010<br><br>@author: M.P. Korstanje<br>
'''<br>import sys<br><br>from PyQt4.QtCore import *<br>from PyQt4.QtGui import *<br><br><br>class Foo(QPushButton):<br><br> barSignal = pyqtSignal((long,),)<br><br> def __init__(self, parent=None):<br> super(Foo, self).__init__("Click!", parent)<br>
<br> self.clicked.connect(self.__emitBarSignal)<br> self.barSignal.connect(self.barSlot)<br> <br> def __emitBarSignal(self):<br> longValue = long(sys.maxint + 1)<br> print "Value that goes in %s" % str(longValue)<br>
self.barSignal.emit(longValue)<br> <br> @pyqtSlot(long)<br> def barSlot(self, value):<br> print "Value that comes out %s" % str(value)<br><br>if __name__ == '__main__':<br><br> app = QApplication(sys.argv)<br>
foo = Foo()<br> foo.show()<br> sys.exit(app.exec_())<br>