i'm trying use python, pyside , sample qml file make simple ui. how can set "value" property available in qml control python app? of now, "speeddial" show up, can't figure out how change it's value.
python file:
import sys pyside.qtcore import * pyside.qtgui import * pyside.qtdeclarative import qdeclarativeview # create qt application , qdeclarative view app = qapplication(sys.argv) view = qdeclarativeview() # create url qml file url = qurl('speeddial.qml') # set qml file , show view.setsource(url) view.show() # enter qt main loop sys.exit(app.exec_())
the qml file:
import qtquick 1.0 item { id: root1 property real value : 0 width: 300; height: 300 image { id: speed_inactive; x: -9; y: 8; opacity: 0.8; z: 3; source: "pics/speed_inactive.png" } image { id: needle x: 136; y: 86 clip: true opacity: root1.opacity z: 3 smooth: true source: "pics/needle.png" transform: rotation { id: needlerotation origin.x: 5; origin.y: 65 angle: math.min(math.max(-130, root1.value*2.6 - 130), 133) behavior on angle { springanimation { spring: 1.4 damping: .15 } } } } }
you're not supposed control qml properties directly python or c++.
define python class represent car property speed
. instantiate in qml that:
car { id: car }
and use speed:
angle: car.speed
Comments
Post a Comment