- Rectangle {
id: relay //如何模仿Qt当中的信号槽的写法 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) } }
如何断开信号槽链接 - Rectangle {
id: relay //...
function removeTelegraphSignal() { relay.messageReceived.disconnect(sendToTelegraph) } }
|