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

Cannot apply QML bindings to a QJSValue

    XMLWordPrintable

    Details

    • Platform/s:
      All

      Description

      We can't create a binding to C++ QJSValue using either the Binding component or Qt.binding() function in QML.

      import QtQuick 2.12
      import QtQuick.Window 2.12
      
      import MyModule 1.0
      
      Window {
          id: window
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          MyObject {
              id: object
              jsValue: "not working" // but binding syntax works
              stringValue: "not working"
          }
      
          Column {
              anchors.centerIn: parent
      
              Text { text: "Binding QJSValue:\t" + object.jsValue }
              Text { text: "Binding QString:\t" + object.stringValue }
          }
      
          Binding { target: object; property: "jsValue"; value: "works" } // does not work
          Binding { target: object; property: "stringValue"; value: "works" }
      }
      
      The attachment contains a minimum reproduce example.
      

        Attachments

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

          Activity

            People

            Assignee:
            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Reporter:
            gpbeta Joshua GPBeta
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes