[PyQt] pyqtSlot, getting "undefined" return values when called from qml javascript
Ville M. Vainio
vivainio at gmail.com
Fri Apr 27 22:57:47 BST 2012
I have a qml file invoking methods on a QObject subclass. I have used
@pyqtSlot decorator to expose the methods as slots.
I can see that the methods are run; however, the return values seem to
be discarded.
Code for the QObject subclass (that I expose with setContextProperty)
is like this:
===
from PyQt4 import QtCore
from PyQt4.QtCore import QObject,pyqtSlot
class NodeWrapper(QObject):
def __init__(self, c,v):
QObject.__init__(self)
self.c = c
self.v = v
@pyqtSlot()
def get_b(self):
return 2
#return self.v.b
@pyqtSlot()
def get_h(self):
return self.v.h
@pyqtSlot()
def children(self):
#self.all = all = [NodeWrapper(self.c, chi) for chi in self.v.children]
all = "hello"
print "Will ret",all
return all
===
I have tried passing return value in the decorator (return=int...).
Any clues where to look?
pyqt version is 4.9.1-2ubuntu1, on Ubuntu precise pangolin.
More information about the PyQt
mailing list