Errors encountered with Maps Demo Tutorial



  • I am trying to create an app that will work with the Ovi Maps. I tried implementing this example: http://doc.qt.nokia.com/qtmobility-1.2/tutorials-mapsdemo-part1.html

    But I have been prompted with 3 errors:
    @/Users/andreibechet/Work/Nokia Project/Qt/Testing/Maps03-build-simulator/../Maps03/geomap.h:16: error: 'MapsWidget' has not been declared@
    @/Users/andreibechet/Work/Nokia Project/Qt/Testing/Maps03-build-simulator/../Maps03/geomap.h:20: error: ISO C++ forbids declaration of 'MapsWidget' with no type@
    @/Users/andreibechet/Work/Nokia Project/Qt/Testing/Maps03-build-simulator/../Maps03/geomap.h:20: error: expected ';' before '*' token@

    Here is the code
    geomap.h
    @#ifndef GEOMAP_H
    #define GEOMAP_H

    #include "mapswidget.h"

    #include <QGraphicsGeoMap>

    QTM_USE_NAMESPACE

    class GeoMap : public QGraphicsGeoMap
    {
    Q_OBJECT

    public:
    GeoMap(QGeoMappingManager *manager, MapsWidget *mapsWidget);
    ~GeoMap();

    private:
    MapsWidget *mapsWidget;

    };

    #endif // GEOMAP_H
    @

    geomap.cpp
    @#include "geomap.h"

    GeoMap::GeoMap(QGeoMappingManager *manager, MapsWidget *mapsWidget) :
    QGraphicsGeoMap(manager), mapsWidget(mapsWidget)
    {
    }
    @

    mapswidget.h
    @#ifndef MAPSWIDGET_H
    #define MAPSWIDGET_H

    #include "mapswidgetprivate.h"

    #include <QWidget>
    #include <QGeoMappingManager>

    QTM_USE_NAMESPACE

    class MapsWidget : public QWidget
    {
    Q_OBJECT

    public:
    MapsWidget(QWidget *parent = 0);
    ~MapsWidget();

    public slots:
    void initialize(QGeoMappingManager *manager);

    private:
    MapsWidgetPrivate *d;

    };

    #endif // MAPSWIDGET_H
    @

    mapswidget.cpp
    @#include "mapswidget.h"

    MapsWidget::MapsWidget(QWidget *parent) :
    QWidget(parent)
    {
    }
    @

    mapswidgetprivate.h
    @#ifndef MAPSWIDGETPRIVATE_H
    #define MAPSWIDGETPRIVATE_H

    #include "geomap.h"

    #include <QGraphicsView>
    #include <QGraphicsScene>
    #include <QGeoCoordinate>

    QTM_USE_NAMESPACE

    class MapsWidgetPrivate
    {
    public:
    GeoMap *map;
    QGraphicsView *view;

    // MapsWidgetPrivate();
    };

    #endif // MAPSWIDGETPRIVATE_H
    @

    mapswidgedprivate.cpp
    @#include "mapswidgetprivate.h"

    void MapsWidget::initialize(QGeoMappingManager *manager)
    {
    d->map = new GeoMap(manager, this);

     QGraphicsScene *sc = new QGraphicsScene;
     sc->addItem(d->map);
    
     d->map->resize(300, 480);
    
     d->view = new QGraphicsView(sc, this);
     d->view->setVisible(true);
     d->view->setInteractive(true);
    
     d->map->setCenter(QGeoCoordinate(-27.5796, 153.1));
     d->map->setZoomLevel(15);
    

    }
    @

    main.cpp
    @#include "mapswidget.h"

    #include <QtGui/QApplication>
    #include <QGeoServiceProvider>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    MapsWidget w;
    w.show();
    
    QGeoServiceProvider *serviceProvider = new QGeoServiceProvider("nokia");
    
    w.initialize(serviceProvider->mappingManager());
    
    return app.exec();
    

    }

    @



  • Did you add mapswidget.h to HEADERS section of your .pro file???



  • Here is the pro file:

    @# Add files and directories to ship with the application

    by adapting the examples below.

    file1.source = myfile

    dir1.source = mydir

    DEPLOYMENTFOLDERS = # file1 dir1

    symbian:TARGET.UID3 = 0xEDF1E0C2

    Smart Installer package's UID

    This UID is from the protected range

    and therefore the package will fail to install if self-signed

    By default qmake uses the unprotected range value if unprotected UID is defined for the application

    and 0x2002CCCF value if protected UID is given to the application

    #symbian:DEPLOYMENT.installer_header = 0x2002CCCF

    Allow network access on Symbian

    symbian:TARGET.CAPABILITY += NetworkServices

    If your application uses the Qt Mobility libraries, uncomment

    the following lines and add the respective components to the

    MOBILITY variable.

    CONFIG += mobility
    MOBILITY += location

    SOURCES += main.cpp
    mapswidget.cpp
    mapswidgetprivate.cpp
    geomap.cpp
    HEADERS +=
    mapswidget.h
    mapswidgetprivate.h
    geomap.h
    FORMS += mainwindow.ui

    Please do not modify the following two lines. Required for deployment.

    include(deployment.pri)
    qtcAddDeployment()
    @



  • There is a circular inclusion of header files.. that causes the problem

    mapswidget.h has mapswidgetprivate.h included
    mapswidgeetprivate.h has geomap.h include
    geomap.h has mapswidet.h included

    To solve it
    @#ifndef GEOMAP_H
    #define GEOMAP_H

    //#include "mapswidget.h" // remove this line Vijaya Bhaskar Reddy

    #include <QGraphicsGeoMap>

    QTM_USE_NAMESPACE

    class MapsWidget; //add this line Vijaya Bhaskar Reddy
    class GeoMap : public QGraphicsGeoMap
    {
    Q_OBJECT

    public:
    GeoMap(QGeoMappingManager *manager, MapsWidget *mapsWidget);
    ~GeoMap();

    private:
    MapsWidget *mapsWidget;

    };

    #endif // GEOMAP_H@

    And
    @
    #include "mapswidgetprivate.h"
    #include "mapswidget.h" // this is what I have added Vijaya Bhaskar Reddy

    void MapsWidget::initialize(QGeoMappingManager *manager)
    {
    d->map = new GeoMap(manager, this);

     QGraphicsScene *sc = new QGraphicsScene;
     sc->addItem(d->map);
    
     d->map->resize(300, 480);
    
     d->view = new QGraphicsView(sc, this);
     d->view->setVisible(true);
     d->view->setInteractive(true);
    
     d->map->setCenter(QGeoCoordinate(-27.5796, 153.1));
     d->map->setZoomLevel(15);
    

    }
    @



  • Thank you for the reply, but it still doesn't work. Here are the errors ... really odd ones too.

    @:-1: error: symbol(s) not found for architecture x86_64@
    @:-1: error: collect2: ld returned 1 exit status@



  • What is your OS.



  • Mac OS 10.6.8 with QT Creator 2.2.1





  • Thank you. I will look for my solution there.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.