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

QML model cannot store JS function

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4: Low P4: Low
    • None
    • 5.4.0
    • None
    • Qt 5.4 on Kubuntu 15.04

      It is not possible to have a JS function inside the model of eg. a Repeater and then trigger it. Neither from the delegate using modelData.trigger() nor by accessing it by index.

      Repeater {
          model: [
              {
                  label: "Trigger",
                  trigger: function() {
                      console.log("Hello")
                  }
              }
          ]
      
          Button {
              text: modelData.label
              onClicked: modelData.trigger()
          }
      }
      

      Clicking the button will just yield an error rather than invoking the function.

      TypeError: Property 'trigger' of object [object Object] is not a function

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

            srutledg Shawn Rutledge
            broulik Kai Uwe Broulik
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes