We have an existing QT project written in C++, and we want to add something like the mapViewer example project to our existing UI. We can't figure out how to instantiate the mapViewer, and invoke the method that initializes/displays it. Following online help, we came up with the function below, that returns a QQuickWidget which we can add to a UI element. We keep getting an error that the created component never gets to be ready, so the function does not work.
QQuickWidget *buildMap(QWidget *parent)
QQmlEngine *engine = new QQmlEngine;
QQmlComponent component(engine, "qrc://mapviewer.qml");
QObject *object = component.create();
QQuickWidget *map = new QQuickWidget(engine, parent);
It does not make a ton of sense to us that we are creating an object using the mapViewer component, and then just forgetting about it, but the examples we found online have a flow similar to this.