Details
Description
`QObject.sender()` returns None when called within a slot which was inherited from a superclass.
In this example the second output line should be an instance of `_main_.B`:
from PySide6 import QtCore class A(QtCore.QObject): @QtCore.Signal def mySignal(self): ... def __init__(self) -> None: super().__init__() self.mySignal.connect(self.mySlot) @QtCore.Slot() def mySlot(self): print(self.sender()) class B(A): ... if __name__ == "__main__": a = A() b = B() a.mySignal.emit() b.mySignal.emit()
Output:
<__main__.A(0x18498f7dd20) at 0x0000018499327380> None
Attachments
Issue Links
- duplicates
-
PYSIDE-1295 Sender from signal with private callback is None
- Closed
- is duplicated by
-
PYSIDE-2327 self.sender() is None if @Slot decorator is used
- Closed
For Gerrit Dashboard: PYSIDE-2144 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
447481,4 | Fix QObject::sender() for non-C++ slots | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |