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

QML model cannot store JS function

    XMLWordPrintable

Details

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

    Description

      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

      Attachments

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes