1

I use Qt for Python for a while now and find myself often asking: What is the usefulness of the Slot() decorator? If I connect to a signal the documentation says I should decorate my callable function with the Slot() decorator. But is there any computational necessity or advantage in doing so? The following example connects two slots to the "pressed"-signal of a button. Both functions will work perfectly fine.

self.btn.pressed.connect(self.on_btn_pressed1)
self.btn.pressed.connect(self.on_btn_pressed2)

@Slot()
def on_btn_pressed1:
    print("Hello")

def on_btn_pressed2:
    print("World")
MrLeeh
  • 5,321
  • 6
  • 33
  • 51
  • The documentation gives a hint: "Unlike the Signal() class, to overload a function, you don't pass every variation as tuple or list. Instead, you have to define a new decorator for every different signature." It then provides examples where you have more than one `@Slot` decorator for a function. – Giacomo Alzetta Feb 25 '20 at 11:13

0 Answers0