PyQt4,How to add a batch of widget (QPushButton) at one time and lets them to execute on SLOT
pyqt, python, sender, signals
Solution
When you are in a slot, you can use sender() method (just call self.sender()) and you will receive a reference to the object, from which signal was emitted. Here is documentation about it.
Problem
if i want to add 10 QPushButton at one time: ``` NumCount=20 for i in range(NumCount): btn=QPushButton("%s %s" %("Button" i+1),self) btn.clicked.connect(self.btnclick) def btnclick(self): # here is my question # how to define which button clicked? # how to print btn.text? ``` as stated in the def(btnclick).