PyQt slot return value
-
Any help with this would be appreciated, including hints on how to debug further.
The pyqtSlot decorator takes a result as one of the parameters. However, I'm lost as to how to use it. Here's code to replicate my minimal problem.
@
import sysfrom PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObjectclass TestSlot( QObject ):
newTrigger = pyqtSignal() def __init__( self ): super( TestSlot, self ).__init__() def doIt( self ): print "Call: doIt" test = self.newTrigger.emit() print "emit return val: %s" % test @pyqtSlot( result = str ) def myTestFunction( self ): print "Call: myTestFunction" result = "Here's a return value" return "Even returning a string"
app = QApplication( sys.argv )
w = TestSlot()
w.newTrigger.connect( w.myTestFunction )the_return_val = w.doIt()
print "Doit return value: %s" % the_return_val
@The results from this are:
@➜ python testme.py
Call: doIt
Call: myTestFunction
emit return val: None
Doit return value: None
@Where is my return value?
-
-
@pyqtSlot( result = str ) is only for the C++ declaration.
you can not use the return value with an emit Event. ;-(see http://stackoverflow.com/questions/11272951/pyqt4-pyqtslot-what-is-the-result-kwarg-for