ListModel defined in C++, trying to print count in QML
I have a ListModel in C++ defined as
QList<QObject*> myModel [...] setContextProperty("myModel", QVariant::fromValue(myModel));
On the QML side i want to see how many items are in the list... but when i try something like
console.log("list size: " + myModel.count)
all i see print out is
list size: undefined
@poncho524 Did you try myModel.count()? It's a function, not a property.
According to this (http://doc.qt.io/qt-5/qml-qtqml-models-listmodel.html) "count" is a property.
However, I did try count() and it gave a bigger error.
Actually QList doesn't have properties or slots and it's not even a QObject so you can't use its functions in QML. It's possible that you have to implement a QAbstractItemModel C++ model if you want to handle the model in both C++ and QML.