Hi all,
I'm trying to write a simple QML/PySide demo application.
It seems that I'm missing to register my classes and so I can't use them
for exchanging data between
PySide and QML.
Here is a smaller example which reproduces the error:
----------------------------------------------------------------
pyside-test01.py
----------------------------------------------------------------
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtDeclarative import QDeclarativeView
class Foo(object):
def __init__(self, text):
self._text = text
if __name__ == "__main__":
app = QApplication(sys.argv)
view = QDeclarativeView()
"""
assigning the 'foo' property will raise:
pyside-test01.qml:10: Unable to assign PySide::PyObjectWrapper to
QString
"""
view.rootContext().setContextProperty("foo", Foo("foo"))
view.rootContext().setContextProperty("bar", "bar")
view.setSource(QUrl('pyside-test01.qml'))
view.show()
sys.exit(app.exec_())
----------------------------------------------------------------
pyside-test01.qml
----------------------------------------------------------------
import QtQuick 1.0
Rectangle {
width: 360
height: 360
Rectangle {
anchors.fill: parent
Row {
Text { text: foo }
Text { text: bar }
}
}
}
thank you for your attention.
--
Filippo Santovito
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside