[Development] On QML, ownership, QObject-trees and QSharedPointer
rene at catatonic.dk
Fri Jun 1 10:40:39 CEST 2012
> Step 1: mySharedPtr.data() ==> MyShared* P;
>> Step 2: make sure the QML engine doesn't assume ownership:
>> Step 3: hand over P to QML: setProperty or setContextProperty
> Yep, those steps seem to be the current requirement. If my patches get in
> (not guaranteed), it will be reduced to just:
> Step 1: setContextProperty("myname", mySharedPtr);
> Step 1: setContextProperty("myname", mySharedPtr.toWeakRef());
> depending on your needs.
>> When I said the database layer should preferably remain QML agnostic,
>> I merely wanted to keep "patchup code" like "setObjectOwnership" out
>> of a clean set of data classes for purist reasons. (Really it is an
>> exaggeration imho.. I have no problem using stuff from QtDeclarative
>> in code. Will need it for QList properties anyway. It's just a design
> Yes, I agree.
> Leaving out step 2 is bad, right?
> Yes, and worse it might not obvious to consumers of the API that it's
I have modified the wiki page that Sivan started (my name in
qt-project.orgis "Centipede"). In my view your advice above is serious
enough to warrant
a user comment in the footnote section of at least the documentation pages
of 4.8. But I cannot for the life of me figure out where to add such
comments. Is qt-project.org's user comment system up and running?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Development