[PyKDE] QPushButton

Fredrik Juhlin laz at strakt.com
Tue Sep 2 11:25:01 BST 2003


GuineaPig wrote:
> I'm working with pyQt and I have a widget with 40 QPushButtons 
> (toggles).  On 'toggled()' the buttons emit a signal to a function.  In 
> this function I'd like to find out wich button was pressed.  I'm 
> thinking about iterating through all the buttons to check theirs state 
> but I can't seem to find how to do this in the docs.  Can someone point 
> me in the right direction ?  Should I handle this differently ?
You might want to look at QButtonGroup. If you add all your buttons to a 
button group, you can listen to QButtonGroup.clicked()to find out what 
button was clicked.

If that doesn't work for you you'll probably have to subclass 
QPushButton and create your own signal that supplies the button itself 
to the slot.


More information about the PyQt mailing list