Qt.binding behavior changed after 5.7.1



  • Hello all,

    Not sure it's the best title to explain but I'm using Qt.Binding as a pointer on function to separate a list in 2.

    this is rough example of what I have but should explain what's going on.

    property list<Actions> actions
    
    function filter(list, func) {
      var result = []
      for (var i = 0; i < list.length; i++)
      if (func(list[i])) {
        result.push(list[i])
      }
      return result
    }
    
    property var list1: filter(actions, Qt.binding( function(item) { return item.enabled }))
    property var list2: filter(actions, Qt.binding( function(item) { return !item.enabled }))
    
    

    When using 5.7.1, updating the property enabled of an item, it will automatically trigger the update of the lists, however this behavior doesn't work anymore with 5.9.1
    in filter model func is seen as a function object function() { [code] } but when trying to execute it will return undefined

    I'm not sure if it's a regression or a fix, but if anyone could help me to determine what's going on, I would be most grateful.



  • I am not sure your use of Qt.binding was supported.

    As a workaround you could force the reevaluation of the expression by accessing item.enabled like so :
    property var list1: {item.enabled; return filter(actions, function(item) { return item.enabled })



  • Thanks that worked !


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.