trollixx

Using function as QML model property (hack)

Jun 16th, 2015
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 0.38 KB | None | 0 0
  1. Repeater {
  2.     id: repeater
  3.     property var _model: [{
  4.             "title" : "HAHA",
  5.             "color" : "#3498db",
  6.             "func" : function () { console.log("FUNC!") }
  7.         }];
  8.     model: _model
  9.  
  10.     Button {
  11.         text: modelData.title
  12.         onClicked: repeater._model[index].func()
  13.         // Does not work:
  14.         // onClicked: modelData.func()
  15.     }
  16. }
Add Comment
Please, Sign In to add comment