在函数体内触发属性更新。
import QtQuick 2.0
Rectangle {
property int i: 0
width: 640
height: 480
Text {
text: changed()
}
Timer {
interval: 1000; running: true; repeat: true
onTriggered: i++
}
function changed() {
return i
}
}
text:changed()
应该为函数的返回值0,由于changed函数内存在外部变量就不一定是0了;