We've only exposed the existing C++ objects to JavaScript so far, but what if you want to create a new C++ object from JavaScript? You can do this using what you already know. A C++ method of an already exposed object can create a new object for you:
public: Q_INVOKABLE QObject* createMyObject(int argument) { return new MyObject(argument); }
Using this method from JavaScript is also pretty straightforward:
var newObject = originalObject.createMyObject(42); newObject.slot1(); ...