Hi,
As I see in Interacting with QML Objects from C++ [qt-project.org], the way to Create QML Object in C++ is like this:
// Using QQmlComponent
QQmlEngine engine;
QQmlComponent component(&engine,
QUrl::fromLocalFile("MyItem.qml"));
QObject *object = component.create();
...
delete object;
This is a static way as we must write a qml file in advance, how to create an qml object dynamically?
Maybe something like this: create(“Rect”)?
If so, we can register a C++ class, MyClass for example, to QML engine and use it in C++ like this create(“MyClass”), right?
Is there any way to create JavaScript object in C++ directly?
↧