[Interest] Best model type for shared data between C++ and QML, as well as insertion and removal on both sides.

Ben Lau xbenlau at gmail.com
Fri Nov 21 05:28:57 CET 2014


On 21 November 2014 06:40, Nuno Santos <nunosantos at imaginando.pt> wrote:

> I have subclassed QAbstractListModel and i’m already able to have the
> model listed in a list view.
>
> What I can’t find is how I programmatically add items to the model from
> the QML side and which methods I need to reimplement in my model class.
>
> The qml-object-model you have sent me is probably old because there aren’t
> the same methods on the documentation for Qt 5.3
>
> Suggestions?
>
>
>
ah , I have forgotten that I have modified the code to get it work on Qt 5.
However, you may still refer to the append() / insert() / move() functions
. Those beginXXX and endXXX should be valid for Qt 5. The help to setup the
signal and make it behave like a ListModel. Therefore , you may add data to
the model via append() / insert() calls by QML just like a ListModel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141121/410aee17/attachment.html>


More information about the Interest mailing list