Pyside, declarative: Returning a value from a slot
-
Hi,
Been playing with python/QML and slots returning values, but things dont seem to work well when you do something like:
@
class Communicate(QtCore.QObject):
def init(self):
super(Communicate,self).init()
self.r = 0
self.s = "heloo"@QtCore.Slot(result=int)
def val(self):
v = self.r + 10
return v@QtCore.Slot(result=str)
def giveit(self):
return self.s
@and then in the QML :
@helloText.text = getstuffdone.val()@the Value is always shows up 1
and it is same for returning strings. The returned string is empty.and I also checked with the pyside examples and it does same issue (see example qmltopy2), the rotation does not pick up.
any idea how to make it work?
-
oo and in my main.py i aslo do :
@
if name == "main":
import sysinitiate the main QML application
app = QtGui.QApplication(sys.argv)
myClass
view = QtDeclarative.QDeclarativeView()
getstuffdone = Communicate()
timer = QtCore.QTimer()
timer.start(2000)
context = view.rootContext()context.setContextProperty("getstuffdone", getstuffdone)
view.setSource(QtCore.QUrl('book.qml'))
view.show()
execute
sys.exit(app.exec_())
@ -
hi adhorn, this was fixed on PySide git version. A new version with this and others bugs fixes will be released soon.