[Development] QML and QAbstractListModel

Alberto Mardegan mardy at users.sourceforge.net
Mon Jan 14 12:37:55 CET 2013


On 01/14/2013 11:37 AM, André Somers wrote:
[...]
> top of them. Note that you can also use a proxy to map a table model to
> a list by mapping the data in columns to different roles. The base class
> would not be a QListModel, but the data would be available from the
> first column anyway. When using the proxy approach I suggest, that works
> nicely. Your approach only works for models that derive from
> QAbstractListModel directly.

Very good point. Maybe this helper class could help expose more complex 
models to QML as a list model, by providing a sub-selection of the data. 
Something like:

============
ItemModel {
     id: itemModel
     model: myModel
     column: 4
}

ListView {
     model: itemModel
}
============

where "myModel" could be a tabular QAbstractItemModel, and in 
"itemModel" we select the 4th column in order to create a list model. 
Though whether it's useful, it's another matter. :-)

Ciao,
   Alberto



More information about the Development mailing list