Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.3.2
-
None
Description
As deponstrated in this testcase, javascript function are not preserved when used in object within a model.
import QtQuick 2.3 import QtQuick.Window 2.2 Window { //Imagine this is a component that is meant to be re-usable // the users of this compontent would then fill the model like this property var actionList: [ { text: qsTr("Hello"), enabled: true, action: function() { console.log("Hello") } }, { text: qsTr("World"), enabled: true, action: function() { console.log("World") } } ]; title: qsTr("Hello World") width: 640 height: 480 Column { width: parent.width; spacing: 10; Repeater { id: rep model: actionList; Rectangle { width: parent.width; height: 60; border.color: "black" border.width: 2; Text { anchors.centerIn: parent; text: modelData.text; } MouseArea { anchors.fill: parent; onClicked: { if (modelData.action) { modelData.action(); // BUG!!! does not work // TypeError: Property 'action' of object [object Object] is not a function // rep.model[index].action(); // Also does NOT work //Workaround: this works //actionList[index].action(); } } } } } } }
Attachments
Issue Links
- relates to
-
QTBUG-69771 Functions in QML model data not accessible
- Open