I need to use pyqtSlot() decorator in order to expose a python function to javascript code.
The return type is list so i should write:
@pyqtSlot(result=list)
But i get an error:
"TypeError: unable to convert a Python 'list' object to a C++ 'PyQt_PyObject' instance"
I made some research but yet couldnt find an answer.
According to pyqt doc i can return any python type object or a string specifying a C++ type, so i tried result='array'.
But it doesnt work or i do something wrong.
@pyqtSlot(result=list)
def getCodeList(self):
return self.codeList
I think i found a way.
I just wrap python list with QVariant() and return QVariant.
@pyqtSlot(result=QVariant)
def getCodeList(self):
return QVariant(self.codeList)
Thanks QVariant.
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