A Diumenge, 20 de juny de 2010, Albert Cervera i Areny va escriure: > We're changing an application from using old-style 'connect(SIGNAL() > SLOT())' functions to new-style 'signal.connect( slot )' ones but it > seems that executing 'self.sender()' in the slot doesn't have the same > behaviour as it used to because it always returns None. > > Is there a way to know who called the slot with new-style signal and slot?
The attached file demonstrates the problem. sender() function doesn't work if signal is emited using the new-style signal.emit() and the slot is decorated using @pyqtSlot() > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > > > _______________________________________________ > PyQt mailing list [email protected] > http://www.riverbankcomputing.com/mailman/listinfo/pyqt -- Albert Cervera i Areny http://www.NaN-tic.com OpenERP Partner Mòbil: +34 669 40 40 18
from PyQt4.QtCore import * class A(QObject): signal1 = pyqtSignal() signal2 = pyqtSignal() def __init__(self): QObject.__init__(self) self.signal1.connect( self.slot1 ) self.signal1.emit() self.signal2.connect( self.slot2 ) self.signal2.emit() @pyqtSlot() def slot1(self): print "SLOT1: ", self.sender() def slot2(self): print "SLOT2: ", self.sender() o = A()
_______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
