[Development] Q_INVOKABLE QAbstractListModel
md at rpzdesign.com
md at rpzdesign.com
Sat May 23 19:51:09 CEST 2015
Konstantin:
Maybe you could add some useful guidance to your response.
The point of interest is that it must be a QObject derived return.
Maybe a pointer to a QObject.
Or maybe there is another way to construct QAbstractListModel that will
allow for a non-pointer return from Q_INVOKABLE?
(But that would be on the stack likely)
More comments appreciated,
mark
On 5/23/2015 11:38 AM, Konstantin Ritt wrote:
>
> 2015-05-23 21:20 GMT+04:00 mark diener <rpzrpzrpz at gmail.com
> <mailto: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
>
>
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
More information about the Development
mailing list