I've been trying to migrate an application from Qt 4.6.2 to 4.7.0, and had a problem in 4.7 where I can only successfully connect a certain number of signals.
I've written a simple test program in Python using the PySide bindings that demonstrates the problem. In the test program, on each timer timeout, a new signal is defined and connected to a callback, and all signals defined thus far are emitted. The source-code for this small test is in attached test.py and also listed at the bottom of this post.
Using Qt 4.6.2, this works as I expected, with the output in attached qt4.6.2output.txt
$ python test.py
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
$ python test.py
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
To copy to clipboard, switch view to plain text mode
But using Qt 4.7.0, the callback is not called for new signals after a limit has been reached: in the example the limit was 11. The output is in attached 4.7.0output.txt.
$ python test.py
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
$ python test.py
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11
To copy to clipboard, switch view to plain text mode
The system with Qt 4.6.2 installed runs Ubuntu 10.04
$ cat /proc/version
Linux version 2.6.32-26-generic (buildd@rothera) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #48-Ubuntu SMP Wed Nov 24 09:00:03 UTC 2010
$ apt-cache show libqtcore4
...
Version: 4:4.6.2-0ubuntu5.1
$ cat /proc/version
Linux version 2.6.32-26-generic (buildd@rothera) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #48-Ubuntu SMP Wed Nov 24 09:00:03 UTC 2010
$ apt-cache show libqtcore4
...
Version: 4:4.6.2-0ubuntu5.1
To copy to clipboard, switch view to plain text mode
The system with Qt 4.7.0 installed runs Ubuntu 10.10
$ cat /proc/version
Linux version 2.6.35-24-virtual (buildd@vernadsky) (gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5) ) #42-Ubuntu SMP Thu Dec 2 05:01:52 UTC 2010
$ apt-cache show libqtcore4
...
Version: 4:4.7.0-0ubuntu4
$ cat /proc/version
Linux version 2.6.35-24-virtual (buildd@vernadsky) (gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5) ) #42-Ubuntu SMP Thu Dec 2 05:01:52 UTC 2010
$ apt-cache show libqtcore4
...
Version: 4:4.7.0-0ubuntu4
To copy to clipboard, switch view to plain text mode
Here is the source code for the example:
import sys
from PySide import QtCore, QtGui
def __init__(self):
super(Window, self).__init__()
self.
timer = QtCore.
QTimer(self
) self.timer.timeout.connect(self.onTimeout)
self.n = 0
self.timer.start(1000)
@QtCore.Slot()
def onTimeout(self):
exec("Window.sig%d = QtCore.Signal(object, object)" % self.n)
eval("self.sig%d" % self.n).connect(self.onSignalN)
for i in xrange(self.n+1):
eval("self.sig%d[object, object]" % i).emit( i,self )
self.n += 1
print ""
@QtCore.Slot(object, object)
def onSignalN(self, o1, o2):
print o1,
win = Window()
win.resize(320, 240)
win.setWindowTitle("Hello, World!")
win.show()
sys.exit(app.exec_())
import sys
from PySide import QtCore, QtGui
class Window(QtGui.QMainWindow):
def __init__(self):
super(Window, self).__init__()
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.onTimeout)
self.n = 0
self.timer.start(1000)
@QtCore.Slot()
def onTimeout(self):
exec("Window.sig%d = QtCore.Signal(object, object)" % self.n)
eval("self.sig%d" % self.n).connect(self.onSignalN)
for i in xrange(self.n+1):
eval("self.sig%d[object, object]" % i).emit( i,self )
self.n += 1
print ""
@QtCore.Slot(object, object)
def onSignalN(self, o1, o2):
print o1,
app = QtGui.QApplication(sys.argv)
win = Window()
win.resize(320, 240)
win.setWindowTitle("Hello, World!")
win.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Ranen
Bookmarks