On Fri, 11 Oct 2013 18:16:07 +0200, Nils Jeisecke <[email protected]> wrote:
> Hi Paul, > > On Fri, Oct 11, 2013 at 5:29 PM, Paul Lemire <[email protected]> > wrote: >> On a side note, those models are not registered as qml properties but >> are >> returned as QObject* in a Q_INVOKABLE methods of the backend. If I want >> to >> use the model in a ListView, I then do : >> >> ListView >> { >> model : library_name.getMyModel(); >> .... >> } > When returning QObject* from invokable methods, the Qml engine takes > ownership by default. Your object probably gets destroyed at some > point. > > Use QQmlEngine::setObjectOwnership if this is not what you want. > > Why aren't you providing your model pointers as read only properties > instead? > > Nils Thanks Nils, you saved me a lot of time. That explains why my objects suddenly became inaccessible, I'll move them to properties and it will most certainly solve my problem. I used Q_INVOKABLE because it seemed to work and never searched further though I was using properties to store some strings. I should have read the doc better as I didn't know about Qml ownership. Thanks again and sorry about the V4 bug alert. _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
