What's the difference between decorators @pyqtSignature () and @pyqtSlot () pyqt
I was trying to write a slot that connects to various pyqt signals. What I still can't wrap is the difference between the two decorators @pyqtSignature () and @pyqtSlot ().
An example of connecting to pyqt a pushed QPushButton signal that inherits from QAbstractButton, I used the following syntax on_widgetName_signalName
when using @pyqtSignature (""):
@pyqtSignature("")
def on_bn_gpx_select_file_clicked(self):
"""
Run when QPushButton is pressed, or do something
"""
pass
Now when you use @pyqtSlot ()
@pyqtSlot()
def on_bn_gpx_select_file_clicked(self):
"""
Run when QPushButton is pressed, or do something
"""
pass
My question is what is the difference between the two decorators and when should @pyqtSignature or @pyqtSlot () be used
thank
source to share
The decorator pyqtSignature
is part of the old style and syntax of slots , which was superseded by the new style and syntax of slots in PyQt-4.5.
Both decorators serve the same purpose to explicitly mark a python method as a Qt slot and specify a C ++ signature for it (most often to select a specific overload). The only relevant difference between the two decorators is that they pyqtSlot
have a lot more pythonic APIs.
New code should never need to be used pyqtSignature
- it really is necessary for backward compatibility.
source to share