I am attempting to send a JS object (map) to a C++ member function with the following signature
Q_INVOKABLE virtual bool generate(QObject* context);
using
a.generate({foo: "bar"});
The method is being called (confirmed via breakpoint), however, the passed context
parameter is appearing as NULL
. The documentation states that JS objects will be sent as QVariantMap
, so I tried using this signature:
Q_INVOKABLE virtual bool generate(QVariantMap* context);
This resulted in an error during MOC compilation. Next, I attempted:
Q_INVOKABLE virtual bool generate(QVariantMap& context);
but at runtime, QML was unable to find the method (error message indicated "Unknown method parameter type: QVariantMap&").
The documentation only provides an example of sending a QVariantMap
from C++ to QML, not vice versa.
Switching to a public slot
instead of Q_INVOKABLE
yielded the same results and errors.