I have a question about accessing QML components on the C++ side, sorry it might be little beginner.
I am currently working with the sample map view, the app alone works great, but after I try to put this sample together with a navigation panel, it stopped working.
I have added my own main.qml, another page called menu.qml, and renamed the app's original main.qml to map.qml. So now user would require to navigate the panel like this: main.qml -> menu.qml -> map.qml
My problem is: Originally, from the sample, app constructor saves a mapView pointer when it creates main.qml so later it can add markers/change location to the mapview.
It gets mapView pointer by calling:
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
qml->setContextProperty("_mapViewTest", this);
AbstractPane *root = qml->createRootObject<AbstractPane>();
QObject* mapViewAsQObject = root->findChild<QObject*>(QString("mapViewObj"));
mapView = qobject_cast<bb::cascades::maps::MapView*>(mapViewAsQObject);
However, I have changed the name to map.qml, findChild returned as null. Since my app is unable to find mapView, the whole app crushes when I try to set a marker/locate myself.
I tried to QmlDocument::create("asset:///map.qml"), and use the same method as above to find the mapview, and I was able to get it, but nothing happens when I try to put down a marker/locate.
I have also tried to add a new function that calls findChild and get the mapView pointer. The function gets called in onCreationCompleted inside the map.qml page, but mapViewAsQObject still returned null and app crushed.
Any hints would be really appreciated! Thanks