I'm new to Qt, and I'm trying to display the Ovi map.
Unfortunately, my program just crashes. Here is my code:
MapView::MapView(QWidget *parent, const char *name) {
mappingManager = 0;
QGeoServiceProvider *serviceProvider = new QGeoServiceProvider("nokia");
// QGeoSearchManager *searchManager = 0;
// QGeoServiceProvider serviceProvider("nokia");
//QGeoRoutingManager *routingManager = 0;
//routingManager = serviceProvider.routingManager();
if (serviceProvider->error() == QGeoServiceProvider::NoError) {
mappingManager = serviceProvider->mappingManager();
// searchManager = serviceProvider.searchManager();
QGraphicsScene *scene = new QGraphicsScene(this);
QGraphicsView *view = new QGraphicsView(scene, this);
mapGraphics = new QGraphicsGeoMap(mappingManager);
mapGraphics->setMapType(QGraphicsGeoMap::StreetMap);
mapGraphics->setConnectivityMode(QGraphicsGeoMap::HybridMode);
// scene->addText("Map view");
scene->addItem(mapGraphics);
view->show();
} else {
QMessageBox::information(this, "Map", "Service provider error");
}
}
I've commented out the line which I think is causing the crash - the scene->addItem(mapGraphics);
How should I add the mapGraphics so I can see it on screen? I'd really appreciate a hand with this.
Thankyou in advance, J
Have a look at Maps Demo tutorial.
The source code is found in {QtSDK}\Examples\4.7\mobile\mapsdemo\ or on qt.gitorious.org