-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
6.6.0
-
None
I inherit from a class that does not mark its methods with Slot(), which I want to fix during inheritance. Related: How can one attach a decorator to a function "after the fact" in python? - Stack Overflow
This is the code I tried:
from PySide6.QtCore import QObject, Signal, Slot class SuperReceiver(QObject): def receive(self): print("Received") class Receiver(SuperReceiver, QObject): def __new__(cls): instance = super().__new__(cls) # SystemError: <PySide6.QtCore.Slot object at 0x000002004E6A9910> returned a result with an exception set instance.receive = Slot()(instance.receive) # Workaround: # instance.receive = Slot()(lambda slot=instance.receive: slot()) return instance class Signaler(QObject): signal = Signal() receiver = Receiver() signaler = Signaler() signaler.signal.connect(receiver.receive) signaler.signal.emit() print("Done")
However, I am getting a SystemError: <PySide6.QtCore.Slot object at 0x00000190DB949910> returned a result with an exception set
I found a workaround by wrapping the existing method in a lambda, and using that as a decorated slot. It seems to work fine, so I think the overall approach is fine. I just wonder why "instance.receive = Slot()(instance.receive)" doesn't simply work. I think it should.