[Interest] Questions about QML

Oleg Shparber trollixx at gmail.com
Wed Oct 1 03:05:55 CEST 2014


Hi,

I am working on a QML plugin which should provide a set of "modules" with
functionality similar to some of built-in Node.js modules. The requirement
also is that third-party JS libraries created for Node.js should also work
out of the box. While much of the work is straightforward, there are still
some questions I cannot find solutions for.

1. For some reason when I am setting a property on
QJSEngine::globalObject() in my plugin it does not become available in QML.
Example:

static QObject *singletontype_provider(QQmlEngine *engine, QJSEngine
*scriptEngine)
{
    engine->globalObject().setProperty("prop1", "aaa");
    scriptEngine->globalObject().setProperty("prop2", "aaa");
    ...
}

I've tried with both QJSEngine and QQmlEngine passed to the plugin, but
neither works.


2. Can I set new properties of the global object in JS/QML? Trying to set


3. How can I make my C++ type creatable with "new" in QML/JS? I want to
provide several new JS types, but not QML types.


4. Is there a way to provide my own container type? Overloading [] with
Q_INVOKABLE does not work. I'd like to have a custom buffer type which I
can use as myBuffer[index].


5. Is QJSEngine::evaluate() the only method to execute a separate JS file?


6. Can I somehow create a new callable QJSValue using QMetaMethod or lambda
function? It's possible to do from JS side (e. g.
NewType.prototype.newMethod = CppObject.method; works), but I want to do it
from C++ side.


Any help would be very appreciated.

Thanks in advance,
Oleg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140930/266cbdbf/attachment.html>


More information about the Interest mailing list