我不知道为什么会这样。我已经扩展QObject
并添加了宏Q_OBJECT
。此外,信号和插槽都具有相同的参数。
我已经发布了原始问题
这是我的 hpp 文件:
/*
* LocationMonitor.hpp
*
* Created on: Jul 13, 2013
* Author: Roland
*/
#ifndef LOCATIONMONITOR_HPP_
#define LOCATIONMONITOR_HPP_
#include <QObject>
#include <QtLocationSubset/qgeopositioninfo.h>
#include <QtLocationSubset/qgeoareamonitor.h>
using namespace Qt;
using namespace QtMobilitySubset;
class GeoNotification;
class LocationMonitor : public QObject
{
Q_OBJECT
public:
LocationMonitor(int id,GeoNotification *geoNotification,QVariantList locationList,QVariantList actionList);
virtual ~LocationMonitor();
public slots:
void areaEnteredd(QtMobilitySubset::QGeoPositionInfo info);
void areaExitedd(QtMobilitySubset::QGeoPositionInfo info);
public:
QGeoAreaMonitor *monitor;
};
#endif /* LOCATIONMONITOR_HPP_ */
这是我的 cpp 文件
/*
* LocationMonitor.cpp
*
* Created on: Jul 13, 2013
* Author: Roland
*/
#include "LocationMonitor.hpp"
LocationMonitor::LocationMonitor(int id,GeoNotification *geoNotification,QVariantList locationList,QVariantList actionList):
geoNotification(geoNotification)
{
monitor = QGeoAreaMonitor::createDefaultMonitor(this);
QObject::connect(monitor, SIGNAL(areaEntered(QGeoPositionInfo)),this, SLOT(areaEnteredd(QGeoPositionInfo)));
QObject::connect(monitor, SIGNAL(areaExited(QGeoPositionInfo)),this, SLOT(areaExitedd(QGeoPositionInfo)));
}
LocationMonitor::~LocationMonitor() {}
void LocationMonitor::areaEnteredd(QGeoPositionInfo info)
{
}
void LocationMonitor::areaExitedd(QGeoPositionInfo info)
{
}
API 文档链接在这里
谢谢。