Forums

OverviewV-Play 2 Support (Qt 5)Repeater and property bindings › Reply To: Repeater and property bindings

OverviewV-Play 2 Support (Qt 5)Repeater and property bindings › Reply To: Repeater and property bindings
#12132

Günther
V-Play Team

Hi Phil!

Property bindings also work when using a Repeater. The problem here is just that changes within an array (levelsComplete) are not recognized as a change in the property value, thus no bindings are updated. If you copied the array and set the levelsComplete property to the new value, you’ll see that the binding works:

onClicked: {
  currentLevel = modelData

  var copy = []
  for(var i = 0; i < levelsComplete.length; i++)
    copy[i] = levelsComplete[i]

  copy[currentLevel] = 1
  levelsComplete = copy // signals property change
  console.debug(JSON.stringify(levelsComplete))
}

However, I think this is not a very good solution. A better solution would be to manually signal the property change:

onClicked: {
  currentLevel = modelData

  levelsComplete[currentLevel] = 1 // changes within the array do not signal levelsCompleteChanged
  console.debug(JSON.stringify(levelsComplete))
  gameWindow.levelsCompleteChanged() // signal property change manually
}

 

Best,
Günther

 

 

 

  • This reply was modified 2 years, 7 months ago by  GT.
  • This reply was modified 2 years, 7 months ago by  GT.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support