Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

ListView model in C++ not getting all elements

$
0
0
Hi all, I’m facing an issue with a listview that has a model built in c++. Here is how it works : In C++ I have a class, let say MyModel, that subclasses QAbstractListModel. This class has a QList containing C++ Object to display. It also overrides rowCount(…) which returns the number of element in my QList, data(..) that returns the right value according to role and roleNames(). In my main.cpp I create an object of type MyModel and populate its list of element with 4 objects. Once done, I set a context property let say called myModelForQML with this object. In QML my listview has its model property set to myModelForQML. What happens is that it only displays the first element in my Qlist even though there are 4 of them. If I create a model in QML with 4 elements there is no problem, all for of them are displayed correctly. If anyone has an hint of what is going wrong, i would really appreciate it. Thanks.

Viewing all articles
Browse latest Browse all 13965

Trending Articles