The app have QGraphicscene(mpscene)
with QGraphicsView(mpGraphicsView)
i am trying to add qml map object to QGraphicscene(mpscene)
But map view come separately like popup window. How can i add this map to QGraphicscene(mpscene)
?
Following are the few methods i tried as suggested in other posts.
method1
PlaneTrack *blr2bgm = new PlaneTrack; //Cpp object set to root context
QQmlEngine *engine = new QQmlEngine(mpGraphicsView);
QQuickWidget *view = new QQuickWidget(engine, mpGraphicsView);
view->setResizeMode(QQuickWidget::SizeViewToRootObject);
view->rootContext()->setContextProperty("blr2bgm",blr2bgm);
view->setSource(QUrl(QStringLiteral("qrc:/PlaneTrack.qml")));
mpScene->addWidget(view);
method2
PlaneTrack *blr2bgm = new PlaneTrack; //Cpp object set to root context
QQuickView *view = new QQuickView();
view->rootContext()->setContextProperty("blr2bgm",blr2bgm);
view->setSource(QUrl(QStringLiteral("qrc:/PlaneTrack.qml")));
view->setResizeMode(QQuickView::SizeRootObjectToView);
QWidget *container = QWidget::createWindowContainer(view);
container->setMinimumSize(view->size());
container->setFocusPolicy(Qt::TabFocus);
mpScene->addWidget(container);
In PlaneTrack.qml file window container was there that i changed to Item. Following code adds qml to graphic scene.