【发布时间】:2011-08-21 02:31:23
【问题描述】:
我正在使用 C++ 为 maemo 制作 Qt 移动应用程序。
我有我的班级声明,但我收到此错误:
ISO C++ forbids declaration of 'QGeoPositionInfoSource' with no type
我的代码如下:
phonehelper.h
#ifndef PHONEHELPER_H
#define PHONEHELPER_H
#include <QObject>
#include <QGeoPositionInfoSource>
class PhoneHelper : public QObject
{
Q_OBJECT
public:
explicit PhoneHelper(QObject *parent = 0);
void GetGPSData(const char * callbackSlot);
private:
/*
* The error occures here on the line below */
QGeoPositionInfoSource *gpsSource; // PROBLEM HERE
private slots:
void positionUpdated(const QGeoPositionInfo &info);
};
#endif // PHONEHELPER_H
phonehelper.cpp
#include "phonehelper.h"
PhoneHelper::PhoneHelper(QObject *parent) :
QObject(parent)
{
}
PhoneHelper::GetGPSData(const char *callbackSlot)
{
gpsSource = QGeoPositionInfoSource::createDefaultSource(this);
if (gpsSource) {
connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)),
this, SLOT(positionUpdated(QGeoPositionInfo)));
connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)),
this, SLOT(callbackSlot(QGeoPositionInfo)));
gpsSource->startUpdates();
}
}
PhoneHelper::positionUpdated(const QGeoPositionInfo &info)
{
gpsSource->stopUpdates();
delete gpsSource;
}
Project.pro
DEPLOYMENTFOLDERS = # file1 dir1
symbian:TARGET.UID3 = 0xE0EEBE99
symbian:TARGET.CAPABILITY += NetworkServices
# MOBILITY variable.
CONFIG += mobility
MOBILITY += location
SOURCES += main.cpp mainwindow.cpp \
phonehelper.cpp
HEADERS += mainwindow.h \
phonehelper.h
FORMS += mainwindow.ui
include(deployment.pri)
qtcAddDeployment()
上面的错误是什么意思?
【问题讨论】:
-
你忘了说哪一行准确地触发了错误并给出了准确的错误文本。这很重要。
-
亲爱的 Jon.. 我在构建过程中遇到错误,导致它的行是
QGeoPositionInfoSource *gpsSource;在我的 .h 文件中...上面显示了确切的错误文本... -
可能
QGeoPositionInfoSource在某个命名空间中(抱歉,我使用了 QT)。你可以检查一下。 -
你确定
真的被包含了并且它包含 QGeoPositionInfoSource类的声明吗?您可以通过在PhoneHelper类声明之前添加前向声明class QGeoPositionInfoSource;来检查它。
标签: c++ qt header-files maemo qt-mobility