错误:“QtMobility”不是命名空间名称
我正在尝试编译: 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要至少包含一个
QtMobility
标头才能使用该命名空间。此外,
using 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:instead (see QtMobility QuickStart).