Hi Jukka, 2010/12/15 Hugo Parente Lima <[email protected]>: > On Thursday 09 December 2010 17:07:45 Jukka Välimaa wrote: >> Here's a complete example. I run the file containing this, and the only >> message printed is the error I wrote about above; the method is never >> called. If I use int in the test method, everything works fine. >> >> --------------------------------------------------------------------------- >> ----------- from PySide import QtCore >> from PySide.QtGui import QApplication >> from PySide.QtScript import QScriptEngine, QScriptValue >> >> app = QApplication([]) >> >> class Test(QtCore.QObject): >> @QtCore.Slot(list) >> def test(self, param): >> print 'test method called, param is', type(param), param >> >> engine = QScriptEngine() >> test = Test() >> test_qobject = engine.newQObject(test) >> engine.globalObject().setProperty('test', test_qobject) >> >> val = engine.evaluate("test.test([1, 2, 3])") >> print val.toString() >> --------------------------------------------------------------------------- >> ------------------ > > This works in C++? I mean, with the slot signature "Test::test(const > QList<int>& list);"
One idea would be to try and use QVariant as parameter for the slot. Another one is to encode the value using JSON, having a QString as parameter for the slot and using Python's "json" module to decode the data into a Python data structure (for lists of ints, that works nicely). Here's an example how to send data between a WebView and Python using JSON - the same should apply to QScriptEngine as well: http://developer.qt.nokia.com/wiki/Using_QtWebKit_and_QML_with_PySide HTH. Thomas _______________________________________________ PySide mailing list [email protected] http://lists.openbossa.org/listinfo/pyside
