Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

How to pass JS function to a ListModel

$
0
0
Hi, i want to append objects to a ListModel. In the delegate there is a MouseArea.onClicked handle. This handle should call a function that I want to pass to the model. I tried to pass it to an object like this.         var obj = {"label":"OK","callback":function() {console.log('foobar')}};         bottonModel.append(); I can call callback() from obj. That works fine. But in the delegate i can’t call callback() because “Property ‘callback’ of object [object Object] is not a function”. Qml doesn’t pass the function as callable JS function. How can I pass a function to a dynamically created ListElement ?

Viewing all articles
Browse latest Browse all 4972

Trending Articles