显示 QGraphicsGeoMap 时出现问题

发布于 2024-11-28 19:19:53 字数 1281 浏览 1 评论 0 原文

我是 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");
    }
}

我已经注释掉了我认为导致崩溃的行 - scene->addItem(mapGraphics);

我应该如何添加地图图形以便我可以在屏幕上看到它? 我真的很感激你能帮忙。

提前谢谢你,J

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

○闲身 2024-12-05 19:19:53

查看地图演示教程。

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

Have a look at Maps Demo tutorial.

The source code is found in {QtSDK}\Examples\4.7\mobile\mapsdemo\ or on qt.gitorious.org

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文