alpartis / sunrise

sample QtQuick application for my personal training and learning
MIT License
0 stars 0 forks source link

best way to supply a list model to a ListView from C++ #5

Closed alpartis closed 2 years ago

alpartis commented 2 years ago

I have added a ListView to the QML in Page2Form.qml. Currently, as a starting point, I have included a static ListModel containing two elements.

This task is to replace that ListModel with data that is supplied by C++ function.

  1. implement Component.onCompleted code that simply makes a call to a C++ class that supplies the list data for the "girls_list" ListView
  2. remove the "list_of_favorite_girls" ListModel after providing the same data from the C++ function
  3. add a C++ function that will send the necessary list data back to the QML Page to populate the "girls_list" ListView
alpartis commented 2 years ago

To summarize ...

  1. create girls.h that defines a Girl data type and a vector of girls
  2. create qbridge class with a. constructor that pre-loads test data in girls b. method getGirlsList() that returns the girls data converted to a ListModel
  3. update Page2Form.qml Component.onCompleted() to call the getGirlsList() method to retrieve the list data for the girls_list ListView
  4. remove static ListElement data from Page2Form.qml ListModel