[Development] why is QJSEngine not modifying metaObject

Hausmann Simon Simon.Hausmann at theqtcompany.com
Wed Feb 11 08:11:26 CET 2015


The short answer to your question is that the meta object system isn't really designed for this. In theory this could be implemented but it would come at a high cost for something that rarely happens. The qml engine supports this, but in qml this happens at type compilation time, not fully dynamic.


  Original Message
From: Rees, Kevron
Sent: Wednesday, February 11, 2015 00:52
To: development at qt-project.org
Subject: [Development] why is QJSEngine not modifying metaObject


class Test : public QObject {
public slots:
  QObject* createQObject() { return new QObject(); }
  void checkQObjectMetaObject(QObject* obj)
    for(int i=0; i < object->metaObject()->methodCount(); i++)
      qDebug() << "introspecting: " << object->metaObject()->method(i).name();

QJSEngine engine;
QJSValue value = engine.newQObject(new Test());
engine.globalObject().setProperty("test", value);

QString js = ""
"var coolObject = test.createQObject();" \
"coolObject.jsFunc = function() { return true; }"



jsFunc is not listed as a QMetaMethod.  Why?

Development mailing list
Development at qt-project.org

More information about the Development mailing list