Pyqt4 let's you use any python callable as a slot. The decorator actually defines a c++ signature for it as a registered slot
http://pythonxy.googlecode.com/hg-history/4ef4255f59b092a123a5788c821434d9fe94aee9/src/python/PyQt4/PLATLIB/PyQt4/doc/html/new_style_signals_slots.html#the-pyqtslot-decorator " Although PyQt allows any Python callable to be used as a slot when connecting signals, it is sometimes necessary to explicitly mark a Python method as being a Qt slot and to provide a C++ signature for it." ... " Connecting a signal to a decorated Python method also has the advantage of reducing the amount of memory used and is slightly faster." On Mar 3, 2013 9:06 PM, "Panupat Chongstitwattana" <[email protected]> wrote: > Hi. > > I'm experimenting with some code and I'm curious what the > @QtCore.pyqtSlot() decoration does? > I saw it from some other codes, but even without it, testdef() still > returns the widget's name correctly. > > > from PyQt4 import QtGui, QtCore > > > class cb(QtGui.QComboBox): > > def __init__(self): > > super(cb, self).__init__() > > self.setObjectName("test name") > > self.currentIndexChanged.connect(self.testdef) > > for i in range(5): > > self.addItem(str(i)) > > > @QtCore.pyqtSlot() > > def testdef(obj): > > print str(obj.sender().objectName()) > > > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
