How to implement QML ListModel like get method for an QAbstractListModel derived model
I want to use an QAbstractListModel derived model in QML. Binding the model to views already works great. The next thing I want achieve is the ability to access specific items and their role like it is possible with a QML ListModel grid.model.get(index).DisplayRole But I have no idea how to implement this get method in my QAbstractListModel derived model. Any hints? You can add an Q_INVOKABLE function to the QAbstractItemModel derived class like this: ... Q_INVOKABLE QVariantMap get(int row); ... QVariantMap get(int row) { QHash<int,QByteArray> names = roleNames(); QHashIterator<int,