坚持QtQML,坚持移动互联网

http://www.qtcn.org/bbs/u/121778  [收藏] [复制]

toby520

将QtCoding进行到底,做Qt的宠儿

  • 89

    关注

  • 162

    粉丝

  • 3567

    访客

  • 等级:精灵王
  • 身份:论坛版主
  • 总积分:1260
  • 男,1986-11-17

最后登录:2024-03-29

更多资料

日志

QML的信号槽链接实现

2019-03-06 16:33
  1. 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)
          }
      }
  如何断开信号槽链接
  1. Rectangle {
          id: relay
          //...

          function removeTelegraphSignal() {
              relay.messageReceived.disconnect(sendToTelegraph)
          }
      }



分类:默认分类|回复:0|浏览:778|全站可见|转载
 

Powered by phpwind v8.7 Certificate Copyright Time now is:03-29 18:36
©2005-2016 QTCN开发网 版权所有 Gzip disabled