I want to access the storage object inside my CoreProxy instance from a script as below:
CoreProxy proxy(core);
QScriptEngine engine;
QScriptValue coreInScript = engine.newQObject(&proxy);
engine.globalObject().setProperty("acq", coreInScript);
engine.evaluate("acq.storage.start()");
But QScriptEngine gives me this error back:
TypeError: Result of expression 'acq.storage' [undefined] is not an object.
Here is my CoreProxy class:
class CoreProxy : public QObject
{
Q_OBJECT
private:
Core *_core;
public:
CoreProxy(Core *core);
StorageProxy *storage;
public slots:
// Public slots for javascript interactions
QString init(QString acqId);
QString start();
QString stop();
};
And my StorageProxy class:
class StorageProxy : public QObject
{
Q_OBJECT
private:
Core *_core;
public:
StorageProxy(Core *core);
public slots:
// Public slots for javascript interactions
QString start();
QString stop();
};
I've added this in the constructor of StorageProxy, but I didn't manage to access the storage member:
this->setObjectName("storage");
Is something missing in my code?