I have an application which contains ListModel. I have written C++ class derived from QAbstractListModel.
QML List model looks like
// SelectedStepsModel.qml
import QtQuick 2.0
ListModel {
ListElement{
step_name:""
step_icon:""
and, C++ class looks like
class ProductModel : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QString product_name READ get_product_name)
public:
enum {
StepNameRole = Qt::UserRole,
StepIconRole,
...
In main,
...
ProductModel* product_model = new ProductModel();
context->setContextProperty("product_model", QVariant::fromValue(product_model));
...
In one of the files (where QML model gets filled by some functions in QML) I want to replace that logic with newly created model ( as model has all data ).
// some other file
SelectedStepsModel {
id: selected_model
}
selected_model = product_model
Note, here selected_model is ListModel and product_model is QAbstractListModel. But selected_model = product_model is failing.
Am I doing the right thing else what is the correct way of assigning QAbstractListModel to ListModel.
Thanks in advance.
product_model
directly in view?:View{model: product_model}
– eyllanesc