following example in this doc found on sourceforge I faced an 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 the docs you linked, a signal needs to be defined on class level:
class Foo(QObject):
signal = pyqtSignal()
def connectSignal():
self.signal.connect(self.myAction)
@QtCore.pyqtSlot()
def myAction():
print("signal triggered")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With