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. Connect C++ signal to QML function with arguments
Forum Updated to NodeBB v4.3 + New Features

Connect C++ signal to QML function with arguments

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 3.0k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    TheQuakee
    wrote on last edited by TheQuakee
    #1

    I know that there is another thread: http://forum.qt.io/topic/15258/connecting-c-signal-to-qml-function-with-arguments but i still can't connect C++ signal to QML function with arguments.

    I made:

    Connections {
       target: addTabq
    
       onTest: {
       console.log(nick)
       }
    }
    

    addTabq is a function, Test is a name of the signal, and nick is parameter of signal.
    I'm getting:
    QML Connections: Cannot assign to non-existent property "onTest"
    Unable to assign a function to a property of any type other than var.
    QObject::connect: No such slot ApplicationWindow_QMLTYPE_25_QML_76::addTabq(QString)

    edit: okay, i understand now that "target" is Object, so i have to set there class, it's "Layout" then, now I'm getting: "Unable to assign undefined to QObject*".
    My Connections is under ApplicationWindow, it hasn't got any other parents.

    JKSHJ 1 Reply Last reply
    0
    • P Offline
      P Offline
      PSI-lbc
      wrote on last edited by PSI-lbc
      #2

      Maybe this...

      http://developer.nokia.com/community/wiki/Connecting_Qt_signal_to_QML_function

      T 1 Reply Last reply
      1
      • P PSI-lbc

        Maybe this...

        http://developer.nokia.com/community/wiki/Connecting_Qt_signal_to_QML_function

        T Offline
        T Offline
        TheQuakee
        wrote on last edited by
        #3

        @PSI-lbc Yeah, thank you, i have tried this way, but I just tried passing argument as QString not QVariant.

        1 Reply Last reply
        0
        • T TheQuakee

          I know that there is another thread: http://forum.qt.io/topic/15258/connecting-c-signal-to-qml-function-with-arguments but i still can't connect C++ signal to QML function with arguments.

          I made:

          Connections {
             target: addTabq
          
             onTest: {
             console.log(nick)
             }
          }
          

          addTabq is a function, Test is a name of the signal, and nick is parameter of signal.
          I'm getting:
          QML Connections: Cannot assign to non-existent property "onTest"
          Unable to assign a function to a property of any type other than var.
          QObject::connect: No such slot ApplicationWindow_QMLTYPE_25_QML_76::addTabq(QString)

          edit: okay, i understand now that "target" is Object, so i have to set there class, it's "Layout" then, now I'm getting: "Unable to assign undefined to QObject*".
          My Connections is under ApplicationWindow, it hasn't got any other parents.

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by JKSH
          #4

          Hi,

          It's not clear to me how you set up your C++ code and your QML code. Can you show us more detailed code?

          @TheQuakee said:

          I just tried passing argument as QString not QVariant.

          If you're connecting to a JavaScript function, then your C++ signal needs to use QVariant parameters. All JavaScript functions in QML take parameters of var type, which maps to the QVariant type in C++.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          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