[Development] QML and QAbstractListModel

Alberto Mardegan mardy at users.sourceforge.net
Sun Jan 13 12:40:17 CET 2013


On 01/12/2013 11:59 PM, Nils Jeisecke wrote:
> Hi,
>
> what about adding a new Quick item for "enhanced QAbstractItemModel access".
>
> ListModelAdapter {
>    id: myModelAdapter
>    sourceModel: myModel
> }
>
> ListView {
>    model: myModelAdapter.sourceModel
>    delegate: Text {
>      MouseArea {
>        onClicked: console.log(myModelAdapter.data(model.index, "myRole")
>      }
>    }
> }

That would also work just for QAbstractListModel, unless we find a way 
to present QModelIndex to QML.
If the proposal of adding the "count" property and the "get" method to 
QAbstractListModel doesn't get accepted, IMHO the best thing to do is to 
provide either code snippets or a *C++* helper class to help implement 
those things, rather then workaround the limitations from the QML side. 
We are talking about C++ models in any case, so I see more fit a 
solution on the C++ side.

Ciao,
   Alberto



More information about the Development mailing list