[PyQt] Get Signals from all buttons in the form

机械唯物主义 : linjunhalida linjunhalida at gmail.com
Tue Jul 20 02:19:37 BST 2010


or:

buttons = [QPushButton("button %d" % i) for i in range(12)]
for button in buttons:
    button.clicked.connect(lambda button=button: do_something(button))

On Tue, Jul 20, 2010 at 8:57 AM, Doug Bell <dougb at bellz.org> wrote:
> starglider develop wrote:
>> Hi,
>> I have a form with 12 QPushButtons and need to connect the signals to the
>> corresponding  button pressed without have to use the usual
>> self.connect(obj,SIGNAL(),self.function), because I don't khow many buttons
>> where made.
>
> Read the documentation for QButtonGroup.  Set it to non-exclusive, and
> it can signal if any button is pressed.
>
> Doug
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>


More information about the PyQt mailing list