By trial and error I have figured out that one has to initialize pyqtSignal outside __init()__ call like this:
class BackgroundService(QObject):
file_updated = pyqtSignal(name='file_updated')
def __init__(self, slot_method):
super().__init__()
self.file_updated.connect(slot_method)
Otherwise if I do like this
class BackgroundService(QObject):
def __init__(self, slot_method):
super().__init__()
self.file_updated = pyqtSignal(name='file_updated')
self.file_updated.connect(slot_method)
I get an error AttributeError: 'PyQt5.QtCore.pyqtSignal' object has no attribute 'connect'
Why does the signal have to be initialized outside the constructor?