属性设置
一般情况下,使用push("qrc:///pages/xxx.qml")
的方式无法对xxx.qml
进行属性设置.如果需要进行属性设置则使用以下方式:(如果xxx.qml
中存在abcd这个属性的话)
1 2 3 |
stackview.push({item:Qt.resolvedUrl("qrc:///pages/xxx.qml"), properties:{abcd:"H12345"} } ); |
信号连接
可以将当前的item做为参数传递给stackview push Item,然后在Item中连接信号.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Rectangle { id: relay signal messageReceived(string person, string notice) Component.onCompleted: { relay.messageReceived.connect(sendToPost) relay.messageReceived.connect(sendToTelegraph) relay.messageReceived.connect(sendToEmail) relay.messageReceived("Tom", "Happy Birthday") } function sendToPost(person, notice) { console.log("Sending to post: " + person + ", " + notice) } function sendToTelegraph(person, notice) { console.log("Sending to telegraph: " + person + ", " + notice) } function sendToEmail(person, notice) { console.log("Sending to email: " + person + ", " + notice) } } |