Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. always tips "Expected token :"
Forum Updated to NodeBB v4.3 + New Features

always tips "Expected token :"

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 587 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by
    #1

    When I used the code below.it always occured that "expected token :"(heres the onCompleted :)
    I dont know why.how to solve this.

    Component.onCompleted:{
            sendMsg.connect(msgProxy.onSendMsg)
    }
    
    
    J.HilkJ 1 Reply Last reply
    0
    • nicker playerN nicker player

      When I used the code below.it always occured that "expected token :"(heres the onCompleted :)
      I dont know why.how to solve this.

      Component.onCompleted:{
              sendMsg.connect(msgProxy.onSendMsg)
      }
      
      
      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @nicker-player
      you give very little information, for example what is sendMsg ?

      assuming the following:

      Item {
          id: root
          // Assuming sendMsg is a signal and msgProxy is an object with a slot onSendMsg
          signal sendMsg(string message)
      
          Component.onCompleted: {
              root.sendMsg.connect(msgProxy.onSendMsg)
          }
      
          // Example of emitting the signal
          function triggerSendMsg() {
              sendMsg("Hello, World!")
          }
      }
      

      than it should work just fine, maybe there's a typo somewhere above the onCompleted?

      btw, more commonly used is this approach:

      Item {
          id: root
          // Assuming sendMsg is a signal and msgProxy is an object with a slot onSendMsg
          signal sendMsg(string message)
      
          // Define the signal handler directly
          onSendMsg: {
              msgProxy.onSendMsg(message)
          }
      }
      
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      nicker playerN 1 Reply Last reply
      1
      • J.HilkJ J.Hilk

        @nicker-player
        you give very little information, for example what is sendMsg ?

        assuming the following:

        Item {
            id: root
            // Assuming sendMsg is a signal and msgProxy is an object with a slot onSendMsg
            signal sendMsg(string message)
        
            Component.onCompleted: {
                root.sendMsg.connect(msgProxy.onSendMsg)
            }
        
            // Example of emitting the signal
            function triggerSendMsg() {
                sendMsg("Hello, World!")
            }
        }
        

        than it should work just fine, maybe there's a typo somewhere above the onCompleted?

        btw, more commonly used is this approach:

        Item {
            id: root
            // Assuming sendMsg is a signal and msgProxy is an object with a slot onSendMsg
            signal sendMsg(string message)
        
            // Define the signal handler directly
            onSendMsg: {
                msgProxy.onSendMsg(message)
            }
        }
        
        
        nicker playerN Offline
        nicker playerN Offline
        nicker player
        wrote on last edited by
        #3

        @J-Hilk
        I think it may be the space problem.
        When I added the space after the part of the "Component.onCompleted:" ,the error seemed disappeared.So is it possible that the space caused the problem?

        1 Reply Last reply
        0
        • J.HilkJ Online
          J.HilkJ Online
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          space is usually irrelevant, especially behind an assignment :


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved