ISO C++禁止声明没有类型的...

发布于 2024-11-05 10:14:32 字数 1974 浏览 8 评论 0原文

我正在使用 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;
}

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()

Project.pro 以上错误是什么意思?

I'm using C++ to make a Qt mobile application for maemo.

I have my class declaration, but I get this error:

ISO C++ forbids declaration of 'QGeoPositionInfoSource' with no type

My code is following:

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()

What does the above error mean?

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

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

发布评论

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

评论(1

过气美图社 2024-11-12 10:14:32

我没有看到我必须像这样使用 QtMobility 命名空间 using namespace QtMobility;

I did not see that I had to use QtMobility namespace like this using namespace QtMobility;

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