O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Binding groceriesListView.model to groceryItems.list

Binding the ListView model to the list is then just a one-liner in Page1.qml:

// Page1.qml...Page1Form {    addItemButton.onClicked: addGroceryItem.run(addItemField.text)    groceriesListView.model: groceryItems.list    groceriesListView.onItemRemoved: removeGroceryItem.run(itemType)    Component.onCompleted: checkAvailableGroceries.run()}

The list is initially assigned to the model property. Every time the listChanged signal is emitted, the model value is updated form the list value. This happens to the already introduced property binding mechanism: upon update, there is no need to poll data.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required