Hi. See http://developer.qt.nokia.com/wiki/Using_Qt_Properties_in_PySide

As an example:
----------------------------------------------------------------
pyside-test01.py
----------------------------------------------------------------
#!/usr/bin/python
# -*- coding: utf-8 -*-

from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtDeclarative import QDeclarativeView

class Foo(QObject):
    def __init__(self, text):
        QObject.__init__(self)
        self._text = text

    def gettext(self):
        return self._text

    def settext(self, text):
        self._text = text

    textchanged = Signal()

    text = Property(str, gettext, notify=textchanged)

if __name__ == "__main__":
    import sys

    app = QApplication(sys.argv)
    view = QDeclarativeView()
    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 { text: bar }
       }
   }
}
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside

Reply via email to