[Development] QML and QAbstractListModel

Johan Thelin e8johan at gmail.com
Sun Jan 13 13:09:59 CET 2013


Sorry for top-posting. I'm writing from my phone.

I've had a class like this for a project of mine. It exposed signals for
adding, removing and changing rows as well as the count, data and setData
methods.

This helped me peek and poke at a QAbstractLisaModel from JavaScript.

Cheers,

Johan
On Jan 13, 2013 12:40 PM, "Alberto Mardegan" <mardy at users.sourceforge.net>
wrote:

> 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
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130113/79b4fa9e/attachment.html>


More information about the Development mailing list