python 3.x - PyQt5 - Signal : pyqtSignal no method connect -
following example in doc found on sourceforge faced error.
from pyqt5.qtcore import pyqtsignal, pyqtslot def setsignal(): signal = pyqtsignal() signal.connect(self.myaction) @qtcore.pyqtslot() def myaction(): print("signal triggered")
results in
attributeerror: 'pyqt5.qtcore.pyqtsignal' object has no attribute 'connect'
as mentioned in docs linked, signal needs defined on class level:
class foo(qobject): signal = pyqtsignal() def connectsignal(): self.signal.connect(self.myaction) @qtcore.pyqtslot() def myaction(): print("signal triggered")