On Thu, Jan 10, 2013 at 8:46 AM, Alberto Mardegan
<ma...@users.sourceforge.net> wrote:
> 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

+1 from me, those would clearly make it more QML-friendly.

> 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.

I'm on the fence about adding those. Since they wouldn't be commonly
used, maybe it would be better to wait until there's time for a more
holistic 'models in QML' update (which likely means waiting a long
while, but eventually QML and QtQuick will need to deal with the issue
of full tree model support).

> 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.

To my knowledge it's the latter. There's a lot of Qt API which could
be made more QML friendly, especially in this way (just adding
properties and convenience functions, for when a user subclass is
exposed to QML).

--
Alan Alpert
_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to