Hi,

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.


Simon

  Original Message
From: Rees, Kevron
Sent: Wednesday, February 11, 2015 00:52
To: [email protected]
Subject: [Development] why is QJSEngine not modifying metaObject


test:

class Test : public QObject {
Q_OBJECT
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; }"
"test.checkQObjectMetaObject(coolObject)";

engine.evaluate(js);

results:

jsFunc is not listed as a QMetaMethod.  Why?

-Kevron
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to