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. Call object.callbackA.connect(callbackB) in C++

Call object.callbackA.connect(callbackB) in C++

Scheduled Pinned Locked Moved QML and Qt Quick
10 Posts 2 Posters 2.2k 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.
  • A Offline
    A Offline
    aabc
    wrote on last edited by
    #1

    How can I call:

    var object = component.createObject(pageParent);
    object.callbackA.connect(callbackB)

    in C++ ?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      It's all in the "documentation":http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-interactqmlfromcpp.html. And "here":http://qt-project.org/doc/qt-4.8/qtbinding.html#exchanging-data-between-qml-and-c.

      (Z(:^

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aabc
        wrote on last edited by
        #3

        Hey Sierdzio,

        The documantation show how to connect a C++ function.
        I want to connect a JS function to another JS function through C++.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          As long as that function is visible to Meta Object System, it will work. If it's not visible there, it will not work.

          (Z(:^

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aabc
            wrote on last edited by
            #5

            Its a JS function on QML.
            Will it work ?

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              I suppose so. You need to try it. Cast the object to a QObject (or QQuickItem) and then it should be possible to connect signals and slots there.

              (Z(:^

              1 Reply Last reply
              0
              • A Offline
                A Offline
                aabc
                wrote on last edited by
                #7

                But there is now SLOT,
                Just a JS function

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  Try and see. Slots are always connected by name, so maybe the system does not care that it's a JS function.

                  (Z(:^

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    aabc
                    wrote on last edited by
                    #9

                    How do I pass the name of this JS function if on C++ its a QJSValue ?

                    1 Reply Last reply
                    0
                    • sierdzioS Offline
                      sierdzioS Offline
                      sierdzio
                      Moderators
                      wrote on last edited by
                      #10

                      You are about to prove me wrong, I think ;P Maybe try getting it using "QMetaObject::indexOfMethod":http://qt-project.org/doc/qt-5.0/qtcore/qmetaobject.html#indexOfMethod. Or "QMetaObject::normalizedSignature":http://qt-project.org/doc/qt-5.0/qtcore/qmetaobject.html#normalizedSignature.

                      (Z(:^

                      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