To create a nested QAbstractListModel containing a QAbstractListModel
Unsolved
QML and Qt Quick
-
I have a structure i.e., Menu containing sub menu
I'm creating the ListModel in Qt subclassing the QAbstractListModelHere's the code
class MenuItem; class MenuModel : public QAbstractListModel { Q_OBJECT public: enum MenuRoles { NameRole = Qt::UserRole + 1 }; MenuModel(QObject *parent = 0); void addMenu(const MenuItem &menuitem); int rowCount(const QModelIndex & parent = QModelIndex()) const; QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; protected: QHash<int, QByteArray> roleNames() const; private: QList<MenuItem> m_menuItems; }; class MenuItem { public: explicit MenuItem(); ~MenuItem(); void setName(QString name); private: QString m_strName; MenuModel m_subMenuModel; };
However I get compile time error saying " error: C2248: 'QAbstractListModel::QAbstractListModel' : cannot access private member declared in class 'QAbstractListModel' "
Is it possible to structure this way? or is there a better way?
-
Hi,
Where are you getting that error ?
-
What private member are you trying to access ?