[Interest] QML QList<int> as modelData

Alan Alpert 416365416c at gmail.com
Tue Jan 28 20:49:39 CET 2014


On Mon, Jan 27, 2014 at 1:21 AM, Damian Ivanov <damianatorrpm at gmail.com> wrote:
> Hi,
>
> I have QML c++ plugin which I import inside the .qml files using
> import MyPlugin 1.0
> In the plugin I have a QList<int> which I want to expose to .qml for a
> ListView(and other views) as the modelData. What is the right way to
> do it?

You can expose it as a context property,
https://qt-project.org/doc/qt-5/qqmlcontext.html#setContextProperty-2
, on the rootContext() of the QQmlEngine. Or you can make it a
property on a singleton type:
https://qt-project.org/doc/qt-5/qtqml-cppintegration-definetypes.html#registering-singleton-objects-with-a-singleton-type
.

--
Alan Alpert



More information about the Interest mailing list