属性设置
一般情况下, 使用 push("qrc:///pages/xxx.qml")
的方式无法对 xxx.qml
进行属性设置. 如果需要进行属性设置则使用以下方式:(如果 xxx.qml
中存在 abcd 这个属性的话)
stackview.push({item:Qt.resolvedUrl("qrc:///pages/xxx.qml"),
properties:{abcd:"H12345"} } );
信号连接
可以将当前的 item 做为参数传递给 stackview push Item, 然后在 Item 中连接信号.
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)
}
}
正文完