[Development] Q_INVOKABLE QAbstractListModel

Konstantin Ritt ritt.ks at gmail.com
Sat May 23 19:38:42 CEST 2015


2015-05-23 21:20 GMT+04:00 mark diener <rpzrpzrpz at gmail.com>:

> Hello:
>
> I came across a use case where I wanted to return a QAbstractListModel from
> a Q_INVOKABLE in a C++ QObject based class.
>
> The explicit constructor for QAbstractListModel requires a construction of
> these classes that forces the Q_INVOKABLE to return a pointer to the List
> Model instance.
>
> I imagine the explicit constructor suppresses a lot of careless bugs.
>
> But this usage is not currently possible:
>
> Q_INVOKABLE MyQAbstractListModel* getmodel(void)
>
> {
>
>    return (&gmodel) ;
>
> }
>
>
> The QML engine is a bit confused by receiving a pointer to the model
> instead of the entire model itself.
>
> QML Output:
>
> qrc:/main.qml:48: Error: Unknown method return type: MyQAbstractListModel*
>
>
> Maybe someone on the dev list has an idea on how to return a pointer to a
> model from Q_INVOKABLE or maybe someone doing current builds can add a
> AbstractListModel pointer to the known set or method return types in the
> framework for Qt 5.5.x
>
> Anybody's comments appreciated...
>
>
http://doc.qt.io/qt-5/qtqml-cppintegration-topic.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150523/6e6e8355/attachment.html>


More information about the Development mailing list