QML Direct fetch a model from C++
-
@Kofr Yes Ofcourse if using C++ models
- You can return a C++ model and assign it to
model
property - You can use
setContextProperty
to set C++ models and then access from QML
See http://doc.qt.io/qt-5/qtquick-modelviewsdata-cppmodels.html for more info.
- You can return a C++ model and assign it to
-
@p3c0 yeah something like from QML
getModel(2);
means that I want to get nested DataModel like this
QList <QAbstactListModelInheritedModel> List;
return List.at(2);
Shall I create a function which casts my model to QObject and returns this QObject?
-
@Kofr Yes it should work. May be require a list of pointers. Try out.
Shall I create a function which casts my model to QObject and returns this QObject?
Not needed.
model
property will understand any class subclassed fromQAbstractItemModel
or its derivatives. -