I want to display my C++ class as a ListView
in QML. I have an empty vector, which will later be filled:
QList<QObject*> _myList;
and set the context
QQmlContext *ctxt = _eng->rootContext();
ctxt->setContextProperty("modelName",QVariant::fromValue(_myList));
In the qml file I have
ListView {
id: listView
model: modelName
delegate: myDelegate {}
}
But when starting the application I get the following error
qrc:/screen2.qml:252: ReferenceError: modelName is not defined
What am I doing wrong? Strangly, the error does not prevent the list from being correctly displayed once it is filled.