Hi,
I am able to load a map using "Display a map" tutorial.
Now as per my requirement, I want to load this map in QT StackView.
However, when I navigate from my mainMenu to mapScreen using stackview, then map is not loading at all.
Here is my code for your review pls.
Main.cpp
int main(){
qDebug() << "Initializing application";
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
// Linux requires 3.2 OpenGL Context
// in order to instance 3D symbols
QSurfaceFormat fmt = QSurfaceFormat::defaultFormat();
fmt.setVersion(3, 2);
QSurfaceFormat::setDefaultFormat(fmt);
#endif
#if defined(Q_OS_IOS)
Q_IMPORT_PLUGIN(ArcGISRuntimePlugin);
#endif
QApplication app(argc, argv); //QGuiApplication
const QString apiKey = QString("MY_PRIVATE_KEY");
if (apiKey.isEmpty())
{
qWarning() << "Use of Esri location services, including basemaps, requires" <<
"you to authenticate with an ArcGIS identity or set the API Key property.";
}
else
{
QCoreApplication::instance()->setProperty("Esri.ArcGISRuntime.apiKey", apiKey);
}
// Intialize application window
QQmlApplicationEngine appEngine;
appEngine.addImportPath(QDir(QCoreApplication::applicationDirPath()).filePath("qml"));
#ifdef ARCGIS_RUNTIME_IMPORT_PATH_2
appEngine.addImportPath(ARCGIS_RUNTIME_IMPORT_PATH_2);
#endif
mainViewModel=new MainViewModel(&appEngine);
appEngine.load(QUrl("qrc:/Menu/MainMenu.qml"));
auto topLevelObject = appEngine.rootObjects().value(0);
auto window = qobject_cast<QQuickWindow*>(topLevelObject);
if (!window)
{
qCritical("Error: Your root item has to be a Window.");
return -1;
}
window->show();
return app.exec();
}
MainMenu.qml
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
ApplicationWindow
{
id: appWindow
visible: true
width: 1920
height: 1080
StackView {
id: stack
initialItem: view
anchors.fill: parent
}
Item {
id: view
anchors.fill: parent
RowLayout
{
width: appWindow.width
height: appWindow.height
spacing: 2
id:buttonsGrid
Button
{
buttonText: "OPEN MAP"
imagePath: "qrc:///Resources/Icons/settings.png"
Layout.bottomMargin: 60
Layout.leftMargin: 20
function fun() {
stack.push(Qt.resolvedUrl("../qml/map.qml"))
}
}
}
}
}
Map.qml
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Esri.ArcGISRuntime
Item {
id: appWindow
width:1920
height: 1080
visible: true
MapView
{
visible: true
id: myMap
anchors.fill: parent
width:800
height:600
Map
{
initBasemapStyle: Enums.BasemapStyleArcGISStreets
}
}
}Application Console:

Thank you