Here is part of code:
Repeater{
model: [["Text A", function(){console.log("hello A")}],
["Text B", function(){console.log("hello B")}],
["Text C", function(){console.log("hello C")}],
["Text D", function(){console.log("hello D")}]]
delegate: Button{
text: modelData[0]
onClicked: modelData[1](); // Type Error
}
}
I want give different behavior for each button. I think it's supposed to be same as native JavaScript.
var func = function(){
//...
}
func();
How to do this in QML JavaScript?
BTW, now my solution is:
Repeater{
model: ["Text A",
"Text B",
"Text C",
"Text D"]
delegate: Button{
text: modelData
onClicked: {
switch(index)
{
cast 0:
console.log("hello A")
break;
cast 1:
console.log("hello B")
break;
cast 2:
console.log("hello C")
break;
cast 3:
console.log("hello D")
break;
}
}
}
}