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. I thought it would work like the way one can register existing objects with registerContextProperty()... Here is what I'm trying to do: { QString script = m_scriptEditor->ui->txtScript->document()->toPlainText(); if (script.isEmpty()) return; QJSEngine engine; engine.installExtensions(QJSEngine::AllExtensions); if (m_canvas) { QJSValue canvas = engine.newQObject(dynamic_cast<KisCanvas2*>(m_canvas)); engine.globalObject().setProperty("currentCanvas", canvas); } QJSValue part = engine.newQObject(KisPart::instance()); engine.globalObject().setProperty("KisPart", part); QString output = engine.evaluate(script).toString(); m_scriptEditor->ui->txtOutput->document()->setPlainText(output); } -- Boudewijn Rempt | http://www.krita.org, http://www.valdyas.org _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest