[Development] [Interest] [Qt3D] Mixing C++ and QML

Pierre-Yves Siret py.siret at gmail.com
Fri Oct 20 10:06:53 CEST 2017


2017-10-19 20:44 GMT+02:00 Shawn Rutledge <Shawn.Rutledge at qt.io>:

> (thread started on the interest list, but I don’t think my comments belong
> there)
>
> On Oct 19, 2017, at 18:06, Sean Harmer <sean.harmer at kdab.com> wrote:
>
> > Hi,
> >
> > you've hit one of the issues we did with exposing C++ and QML APIs.
> Namely, QQmlListProperty. This thing should ideally never have existed and
> instead support for properties of collections should have been added to
> QObject and the metaobject system.
>
> What exactly do you think should be done there, in case we can fix it some
> day?
>
> QObjects are normally managed as a tree for memory management purposes, so
> I’ve also long disliked the fact that it doesn’t quite match the nesting of
> the Item declarations in QML, because of the separate QList<QQuickItem *>
> childItems.  It’s confusing and wastes memory.
>
> QQmlListProperty is flexible about storage, since you get to write all the
> accessors, so you can maybe use it just for QML and also have normal C++
> API?
>

I have some gripes about QQmlListProperty too, maybe not the same ones.

I agree that having a QQmlListProperty in a class supposed to be used from
c++ looks alien.
Having it supported in the meta object sure looks enticing at a first view.
Maybe with something like Q_LIST_PROPERTY(ElementType list GET getFunction
COUNT countFunction ...).
That ends up being quite like a simplified QAIM without the roles and the
signals.

My other wish would be to be able to populate a QQmlListProperty from a
model, and the general lack of support for models in the QML world (caused
by the need to explicitly add support for models for your types)

For example how do I add series from a model in a ChartView ? (this is
embarrassing for what should be a data driven component)
 How can I populate the new Shape type from a model ? etc.

Some types add explicit support for models, MapItemView for example, but
this seems to be hard. Look at all the bugs related to MapItemView in the
bug tracker (sorry Paolo, it's the first one that came to mind, I don't
mean to be mean ;) ).
And if you eventually manage to do it correctly, you still don't support
dumb models like js array, integer, stringlist... You'll have to bring it
complicated private stuff for it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20171020/c6f7fcfa/attachment.html>


More information about the Development mailing list