Details
Description
Consider the lambda in this loop. It captures the extra parameter b so that setText is called on the correct widget:
for i in range(3): button = QCheckBox("Click me") button.clicked.connect( lambda checked, b=button: b.setText("Checked!" if checked else "Unchecked!"))
As of PySide6 6.6.0, clicking a checkbox in this example raises:
TypeError: <lambda>() missing 1 required positional argument: 'checked'
The signal QAbstractButton::clicked has one argument checked which has a default value.
The issue does not occur when connecting a lambda to a signal that has no default values for its arguments. For example, connecting a similar lambda to QCheckBox::stateChanged works fine:
button.stateChanged.connect(lambda state, b=button: b.setText(f"New state: {state}"))
Note: The attached example file produces the expected results under your competitor's implementation.
Attachments
For Gerrit Dashboard: PYSIDE-2524 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
518545,3 | libpyside: Fix slot names in GlobalReceiverV2 | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
518588,4 | libshiboken: Extend the PyObject debug operator to format code objects | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
518592,3 | libpyside: Port the signal signature code from QString to QByteArray | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
519086,2 | libshiboken: Extend the PyObject debug operator to format code objects | 6.6 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
519087,2 | libpyside: Fix slot names in GlobalReceiverV2 | 6.6 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
521124,10 | libpyside: Avoid parsing signatures in Signal.connect() | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
521125,10 | Enable connecting signals to slots with default parameters | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
521510,8 | libpyside: Remove struct SignalSignature | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
521761,2 | libpyside: Remove QHash used when adding signals from QMetaObject | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
521866,2 | libpyside: Remove struct SignalSignature | 6.6 | pyside/pyside-setup | Status: MERGED | +2 | 0 |