Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-8001

Can't to connect QML signal at script block.

XMLWordPrintable

    • dcd17fa7b77cb6adfb8b21ea90c113915cab9bd5

      After commit

      commit 4a665ff5da05860f5eb46e3982ef3d8163a6cf59
      Author: Aaron Kennedy <aaron.kennedy@nokia.com>
      Date: Fri Jan 15 14:26:53 2010 +1000

      Implement custom QML slot invokation logic

      Previously QML was inefficiently forwarding the task of invoking
      Qt slots to QScript. QML does not implement the more advanced
      argument coercian of QScript and does not support method overloading.
      These two features are only needed to support legacy C++ classes
      (of which QML has none), and are not worth the perf cost to support.

      I can't find way to connect QML signal at script block.

      For example:

      Item {
          id: item
          signal clicked
          width: 100
          height: 100
          MouseRegion {
              anchors.fill: parent
              onClicked: item.clicked()
          }
      
          Component.onCompleted: { item.clicked.connect(test); }
      
          Script {
             function test() {
                print("test");
             }
          }
      }
      

      I found this:

      // Uncomment to use QtScript method call logic
      // QScriptValue sobj = scriptEngine->newQObject(obj);
      // return Value(scriptEngine, sobj.property(toString(name)));
      

      and after uncommenting it works.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            aakenned Aaron Kennedy
            lestorn Nicolay Kartsev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes