0

我正在尝试编译:http ://wiki.forum.nokia.com/index.php/Fetching_a_map_tile_in_Qt_using_Google_Maps

我在 OpenSuse 11.2 上使用 Qt-Mobility 1.2 和 Qt 4.7

我收到的错误是:

MainWindow.h:7: error: ‘QtMobility’ is not a namespace-name
MainWindow.h:7: error: expected namespace-name before ‘;’ token
MainWindow.h:10: error: expected class-name before ‘{’ token
In file included from /opt/qtsdk-2010.05/qt/include/QtCore/qcoreapplication.h:47,
                 from /opt/qtsdk-2010.05/qt/include/QtGui/qapplication.h:45,
                 from /opt/qtsdk-2010.05/qt/include/QtGui/QApplication:1,
                 from main.cpp:2:
/opt/qtsdk-2010.05/qt/include/QtCore/qeventloop.h:51: error: expected initializer before ‘QtCoreModule’
make: *** [main.o] Error 1

我的 .pro 文件包含:

TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .

HEADERS += MainWindow.h
SOURCES += main.cpp MainWindow.cpp

QT += network
CONFIG += mobility
MOBILITY = location

头文件中报错,我展示如下:

#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QPaintEvent>
#include <QPixmap>

using namespace QtMobility;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow ();
    void paintEvent(QPaintEvent* paintEvent);

public slots:
    void handleNetworkData(QNetworkReply* reply);

private:
    void fetchMap(const QSize& size, qreal latitude, qreal longitude);

private:
    QNetworkAccessManager networkAccessManager;
    QPixmap mapPixmap;
}

请指导。

4

1 回答 1

2

您需要至少包含一个QtMobility标头才能使用该命名空间。

此外,该using namespace声明不再是推荐的方式。采用:

 QTM_USE_NAMESPACE

而是(参见QtMobility QuickStart)。

于 2011-05-18T08:24:19.677 回答