Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt.binding behavior changed after 5.7.1

Qt.binding behavior changed after 5.7.1

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 661 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kernelcoffee
    wrote on last edited by
    #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.

    1 Reply Last reply
    0
    • GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      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 })

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kernelcoffee
        wrote on last edited by
        #3

        Thanks that worked !

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved