It is possible to do this in QML:
Item { property var refreshChart: function () {} Component.onCompleted: { refreshChart = function () { console.log("Hello!") } } }
Also, an event handler can be connected dynamically:
Item { TapHandler { id: inputHandler } Component.onCompleted: { inputHandler.tapped.connect(MyScript.jsFunction) } }
or with anonymous function:
function openList() { var list = listSource.getMarkets(sortBy) list.filterChanged.connect(function() { console.log("TableModel has been changed.") }) list.filter = filter ml.model = list }
Rectangle { id: colorbutton width: 200; height: 80; color: "red" TapHandler { id: inputHandler } Component.onCompleted: { color = Qt.binding(function() { return inputHandler.pressed ? "steelblue" : "lightsteelblue" }); } }