[PyQt] Simple connect does not work

Mads Ipsen mpi at comxnet.dk
Fri Apr 24 07:59:28 BST 2009


I am puzzled why the connection used in the example below does not work. I
get the error:

Object::connect: No such slot SpinBox::foo(int)

Example snippet:

import sys
from PyQt4 import QtCore, QtGui

class SpinBox(QtGui.QSpinBox):
    def __init__(self, parent=None):
        QtGui.QSpinBox.__init__(self, parent)

    def foo(self, i):
        print i

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)

    spin = SpinBox()
    QtCore.QObject.connect(spin, QtCore.SIGNAL('valueChanged(int)'),
                           spin, QtCore.SLOT('foo(int)'))


More information about the PyQt mailing list