我是 Qt 的新手,我正在尝试显示 Ovi 地图。
不幸的是,我的程序崩溃了。这是我的代码:
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");
}
}
我已经注释掉了我认为导致崩溃的行 - 场景->addItem(mapGraphics);
我应该如何添加 mapGraphics 以便我可以在屏幕上看到它?我真的很感激这个。
提前谢谢你,J