Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Regular Contributor
xhotkey
Posts: 53
Registered: ‎09-19-2012
My Device: 9700
Accepted Solution

error: 'QGeoPositionInfo' does not name a type

Based on https://developer.blackberry.com/cascades/documentation/device_platform/location/index.html, I tried to build the following codes:

 

/*
 * GPSinfo.h
 *
 *  Created on: Sep 18, 2012
 *      Author: CNTEXIE
 */
//  To start receiving position information,
//  create a default QGeoPositionInfoSource object,
//  connect its positionUpdated() signal to a slot
//  on your receiving object, configure the
//  DefaultGeoPositionSource instance
//  (setPreferredPositioningMethods(),
//  setUpdateInterval())
//  and then invoke startUpdates(). The
//  slot on your receiving object will be
//  invoked as close to the desired update
//  interval as possible, and will be passed
//  the position information in a GeoPosition instance.
#ifndef GPSINFO_H_
#define GPSINFO_H_

#include <QtLocationSubset/QGeoAddress>
#include <QtLocationSubset/QGeoCoordinate>
#include <QtLocationSubset/QGeoPlace>
#include <QtLocationSubset/QGeoPositionInfo>
#include <QtLocationSubset/QGeoPositionInfoSource>
#include <QtLocationSubset/QGeoSatelliteInfo>
#include <QtLocationSubset/QGeoSatelliteInfoSource>
#include <QtLocationSubset/QGeoSearchManager>
#include <QtLocationSubset/QGeoSearchManagerEngine>
#include <QtLocationSubset/QGeoSearchReply>
#include <QtLocationSubset/QNmeaPositionInfoSource>

using namespace bb::cascades;
using namespace std;

class GPSinfo: public QObject {
Q_OBJECT
public:
	GPSinfo();
	virtual ~GPSinfo();
private Q_SLOTS:
	void positionUpdated(const QGeoPositionInfo &info);
};

#endif /* GPSINFO_H_ */

 

/*
 * GPSinfo.cpp
 *
 *  Created on: Sep 18, 2012
 *      Author: CNTEXIE
 */

#include "GPSinfo.h"
using namespace bb::cascades;

GPSinfo::GPSinfo(QObject *parent = 0) :
		QObject(parent) {
	QGeoPositionInfoSource *source =
			QGeoPositionInfoSource::createDefaultSource(this);
	if (source) {
		connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)), this,
				SLOT(positionUpdated(QGeoPositionInfo)));
		source->setPreferredPositioningMethods(
				PositioningMethod::SatellitePositioningMethods);
		source->setUpdateInterval(1000);
		source->setProperty("backgroundMode", true);
		source->startUpdates();
	}
}
void GPSinfo::positionUpdated(const QGeoPositionInfo &info) {
	// Here's where you can do something with the device's position
	qDebug() << "Position updated:" << info;
}

GPSinfo::~GPSinfo() {
	// TODO Auto-generated destructor stub
}

 The results are:

../src/GPSinfo.h:43:29: error: 'QGeoPositionInfo' does not name a type
../src/GPSinfo.h:43:47: error: ISO C++ forbids declaration of 'info' with no type [-fpermissive]
cc: C:/bbndk/host_10_0_6_1/win32/x86/usr/lib/gcc/i486-pc-nto-qnx8.0.0/4.6.3/cc1plus caught signal 1
make[2]: Leaving directory `C:/Users/CNTEXIE/ndk-10.0.6-workspace/xGPSmaster/x86'
make[2]: *** [o-g/.obj/app.o] Error 1
make[1]: Leaving directory `C:/Users/CNTEXIE/ndk-10.0.6-workspace/xGPSmaster/x86'
make[1]: *** [debug] Error 2
make: *** [Simulator-Debug] Error 2

 

Can some one help?

Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: error: 'QGeoPositionInfo' does not name a type

Add this line..

using namespace QtMobilitySubset;

and have this added to your .pro file
LIBS += -lQtLocationSubset
Like all of my posts
Developer
Bluenoser
Posts: 313
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: error: 'QGeoPositionInfo' does not name a type

[ Edited ]

I am having the same problem. Here is my code.

 

#ifndef GPSINFO_H_
#define GPSINFO_H_

#include <QObject>
#include <QtLocationSubset/QGeoPositionInfo>
#include <QtLocationSubset/QGeoPositionInfoSource> using namespace QtMobilitySubset; class GPSInfo: public QObject { Q_OBJECT public: GPSInfo(QObject *parent); ~GPSInfo(); private Q_SLOTS: void positionUpdated(const QGeoPositionInfo &info); }; #endif /* GPSINFO_H_ */

 

#include "gpsinfo.h"

GPSInfo::GPSInfo(QObject *parent = 0) : QObject(parent) {
	QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(this);
	if (source) {
		connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
		source->setPreferredPositioningMethods(PositioningMethod::SatellitePositioningMethods);
		source->setUpdateInterval(1000);
		source->setProperty("backgroundMode", true);
		source->startUpdates();
	}
}

void positionUpdated(const QGeoPositionInfo &info) {
	// Here's where you can do something with the device's position
}

GPSInfo::~GPSInfo() {
	// TODO Auto-generated destructor stub
}

 I have included LIBS += -lQtLocationSubset into the .PRO file.

 

I am getting the following errors.

 

../src/gpsinfo.cpp:11:2: error: 'QGeoPositionInfoSource' was not declared in this scope
../src/gpsinfo.cpp:11:26: error: 'source' was not declared in this scope
../src/gpsinfo.cpp:11:35: error: 'QGeoPositionInfoSource' is not a class or namespace
../src/gpsinfo.cpp:14:42: error: 'PositioningMethod' has not been declared

It would be nice for the code sample at https://developer.blackberry.com/cascades/documentation/device_platform/location/ was a little nicer and  worked. How about making it a sample app?

Developer
Bluenoser
Posts: 313
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: error: 'QGeoPositionInfo' does not name a type

Solved it.

 

The code sample is just that, a sample. You cannot use it as a basis for your code. This code compiles.

 

#ifndef GPSINFO_H_
#define GPSINFO_H_

#include <QObject>
#include <QtLocationSubset/QGeoPositionInfo>
#include <QtLocationSubset/QGeoPositionInfoSource>

using namespace QtMobilitySubset;

class GPSInfo: public QObject
{
	Q_OBJECT

public:
	GPSInfo(QObject *parent = 0);
	~GPSInfo();

private Q_SLOTS:
	void positionUpdated(const QGeoPositionInfo &info);

};

#endif /* GPSINFO_H_ */

 

#include "gpsinfo.hpp"

#include <QSettings>

GPSInfo::GPSInfo(QObject *parent) : QObject(parent) {

    QSettings settings;

	QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(this);
	if (source) {
		connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
		source->setPreferredPositioningMethods(QGeoPositionInfoSource::SatellitePositioningMethods);
		source->setUpdateInterval(1000);
		source->setProperty("backgroundMode", true);
		source->startUpdates();
	}
}

void positionUpdated(const QGeoPositionInfo &info) {
	// Here's where you can do something with the device's position
}

GPSInfo::~GPSInfo() {
	// TODO Auto-generated destructor stub
}

 

 

 

Regular Contributor
xhotkey
Posts: 53
Registered: ‎09-19-2012
My Device: 9700

Re: error: 'QGeoPositionInfo' does not name a type

So the key is:

 

QGeoPositionInfoSource::SatellitePositioningMethods

 not:

 

PositioningMethod::smileyfrustrated:atellitePositioningMethods