错误:“QtMobility”不是命名空间名称

发布于 2024-11-08 03:43:12 字数 1710 浏览 6 评论 0原文

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

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

我收到的错误是:

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;
}

请指导。

I am trying to compile: http://wiki.forum.nokia.com/index.php/Fetching_a_map_tile_in_Qt_using_Google_Maps

I am using Qt-Mobility 1.2 with Qt 4.7 on OpenSuse 11.2

The errors I am receiving are:

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

My .pro file contains:

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

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

QT += network
CONFIG += mobility
MOBILITY = location

The error is reported in the header file, which I have shown as follows:

#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;
}

Please guide.

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

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

发布评论

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

评论(1

习惯成性 2024-11-15 03:43:12

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

此外, using namespace 声明不再是推荐的方式。请改用:(

 QTM_USE_NAMESPACE

请参阅 QtMobility 快速入门)。

You'll need to include at least one QtMobility header to be able to use that namespace.

Also that using namespace declaration is not the recommended way anymore. Use:

 QTM_USE_NAMESPACE

instead (see QtMobility QuickStart).

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