Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2144

`QObject.sender()` None if slot is inherited

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4: Low
    • 6.5.0
    • 6.4.1
    • PySide
    • None
    • Windows 10
      Python 3.8.6
    • Windows
    • 5b5cb391c (dev)

    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

        1. pyside2144_diag.diff
          7 kB
          Friedemann Kleint
        2. pyside2144.py
          0.8 kB
          Friedemann Kleint

        Issue Links

          Activity

            People

              kleint Friedemann Kleint
              jamiesanden-refeyn Jamie van der Sanden
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: