Get the root object from QML
-
I have a QML project with the following code in main.cpp
@
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
@How do I get the rootObject so I can access the QML elements to do C++ bindings, all the examples that I have seen , they load the QML with QQuickView, so is it possible to get the root object from QQmlApplicationEngine?.
Thanks
-
- QQmlApplicationEngine::​rootObjects()
- QQuickView::rootObject()
i bet the time writing this post took longer than it would have to check the docs for what you want ;)
-
Hi,
use engine.rootObject() method to get the list of objects.