On 21.02.06 15:31:29, Phil Thompson wrote:
> On Tuesday 31 January 2006 11:41 pm, Andreas Pakulat wrote:
> > Hi,
> >
> > I tried to use sender() in a slot connected to a signal of a QWidget
> > derived class, however sender() always returns a QObject instance
> > instead of the original QWidget-derived one.
> >
> > Is this by purpose and thus sender() is practically not usable in PyQt4
> > or am I just missing something?
> 
> If this is still a problem can you send me a test case?

See attached file, sender() works for a QPushButton but not for the
QWidget derived class.

Andreas

-- 
Don't look now, but there is a multi-legged creature on your shoulder.
from PyQt4 import QtGui,QtCore
import sys
from PyQt4.QtCore import SIGNAL,SLOT,pyqtSignature

class widget1(QtGui.QWidget):
	def __init__(self, parent = None):
		QtGui.QWidget.__init__(self, parent)
	
	def myslot(self):
		print self.sender(), type(self.sender())

class mainwidget(QtGui.QWidget):
	def __init__(self, parent = None):
		QtGui.QWidget.__init__(self, parent)
		self.button = QtGui.QPushButton(self)
		self.button.setText("Test Signal")
		self.test = widget1(self)
		self.connect(self.button, SIGNAL("clicked()"), self.on_button_clicked)
		self.connect(self, SIGNAL("test()"), self.test.myslot)
	
	@pyqtSignature("on_button_clicked()")
	def on_button_clicked(self):
		print self.sender(), type(self.sender())
		self.emit(SIGNAL("test()"))

def main():
    app = QtGui.QApplication(sys.argv)

    main = mainwidget()
    main.show()
    return app.exec_()

if __name__ == "__main__":
    sys.exit(main())
_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to