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

Alex Montgomery apmontgomery at gmail.com
Mon Nov 24 22:35:52 CET 2014


>
> On 21 Nov 2014, at 01:13, Ian Monroe <ian at monroe.nu> wrote:
>
> There's nothing really magical about QAbstractItemModel in QML. They don't
> turn into ListModel's, they are still plain QAbstractItemModel that have
> the methods in C++. Their only superpower is that QML ListView can use it
> as a model.
>
> Just add whatever methods make sense to QAbstractItemModel to insert and
> edit the data and call them from QML.
>
>
I agree with Ian, you can just make functions on your model Q_INVOKABLE, or
you can get your model to listen to signals from your QML items
(delegates). The more you can handle on the C++ side, the easier it'll be
for you. That stuff is discussed a bit in this DevDays talk, but it's
mostly about TreeViews specifically and probably more than you need:
https://www.qtdeveloperdays.com/sites/default/files/north-america/QtQuickTreeView.pdf

Hope that helps,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141124/89d233c1/attachment.html>


More information about the Interest mailing list