[Interest] Adding existing QObjects to QJSEngine

Kai Koehne Kai.Koehne at qt.io
Thu Apr 21 12:47:50 CEST 2016




-- 
Kai Köhne, Senior Manager R&D | The Qt Company

The Qt Company GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja. Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B

> -----Original Message-----
> From: Interest [mailto:interest-bounces+kai.koehne=qt.io at qt-project.org]
> On Behalf Of Boudewijn Rempt
> Sent: Thursday, April 21, 2016 12:29 PM
> To: interest at qt-project.org
> Subject: [Interest] Adding existing QObjects to QJSEngine
> 
> I want to make Krita scriptable, maybe with QJSengine. I'm trying to give the
> js engine access to the existing objects in Krita: the images, documents,
> windows etc.
> 
> From the documentation, I though I would have to use
> QJSEngine.newQObject, but that takes ownership and deletes the objects as
> soon as the engine goes out of scope.

You should be able to change that with QQmlEngine::setObjectOwnership [1]

(yes, it's QQmlEngine, but I'd assume it works nevertheless also for QJSEngine instances).

Regards

Kai 

[1]: http://doc.qt.io/qt-5/qqmlengine.html#setObjectOwnership


More information about the Interest mailing list