[Development] why is QJSEngine not modifying metaObject

Rees, Kevron kevron.m.rees at intel.com
Wed Feb 11 00:52:02 CET 2015


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



More information about the Development mailing list