[Development] QML and QAbstractListModel

Alberto Mardegan mardy at users.sourceforge.net
Thu Jan 10 17:46:14 CET 2013


Hi all!
   I'd like to make C++ models more usable from QML; in the net there 
are several blog posts illustrating how to achieve that, but IMHO it 
would be better if at least some of these handy features were in 
QAbstractListModel itself:

- "count" property
- "get(index)" invocable method, returning a QVariantMap mapping all the 
roles to their data for the specified index

Also, though not very often requested, we could add:
- "remove(index)" which just calls QAbstractItemModel::removeRow()
- "QList<QVariant> items(const QString &role)", which returns the data 
for the role "role" for all items.

The implementation for the above is fairly trivial, so I wonder if 
there's some other reasons why it hasn't been done or if it's just that 
no one did and a patch is welcome.

Ciao,
   Alberto



More information about the Development mailing list