显示QGraphicsGeoMap时出现问题

时间:2011-08-11 09:04:33

标签: qt map qt-creator ovi

我是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

1 个答案:

答案 0 :(得分:0)

查看Maps Demo教程。

源代码位于{QtSDK} \ Examples \ 4.7 \ mobile \ mapsdemo \或qt.gitorious.org