10-08-2012 02:02 AM
Hi,
I created a sample project to fetch GPS coordinates.
This is how I created object of QGeoPostionInfoSource:
positionSource = QGeoPositionInfoSource::createDefaultSource(this);
if (positionSource) {
connect(positionSource,
SIGNAL(positionUpdated(const QGeoPositionInfo &)), this,
SLOT(updateLocation(const QGeoPositionInfo &)));
connect(positionSource, SIGNAL(updateTimeout()), this, SLOT(timeout()));
}
I can fetch updateTimeout() signal when I request for a single location update & if location is not found.
if (positionSource) {
positionSource->setPreferredPositioningMethods(QGe
atellitePositioningMethods);
positionSource->requestUpdate(15000);
}
But I can't fetch same signal when I start regular updates for location & location is not found:
if (positionSource) {
positionSource->setUpdateInterval(2000);
positionSource->setPreferredPositioningMethods(QGe
atellitePositioningMethods);
positionSource->startUpdates();
}
According to documentation it should emit updateTimeout() signal. Am I making any mistake over here? Any kind of help will be highly appreciated.
Thanks,
Nishant Shah
10-09-2012 09:59 AM
Hi,
According to the API docs,
"If requestUpdate() was called, this signal will be emitted if the current position could not be retrieved within the specified timeout.
If startUpdates() has been called, this signal will be emitted if this QGeoPositionInfoSource subclass determines that it will not be able to provide further regular updates. This signal will not be emitted again until after the regular updates resume."
I think what you are seeing is expected. When you call startUpdates() for continuous fixes, the updateTimeout() wont be called until the underlying location module determines that it wont be able to provide any fixes at this time. However, for single update, (requestUpdate()) the API is correctly firing updateTimeout() after the specified timeout value.
If you want to specify a timeout for continuous fixes, you may try:
positionSource->setProperty("responseTime", "15000");
This will force the underlying location module to return a fix within 15 seconds.
Shadid
10-19-2012 08:55 AM
Thanx Shaque for replying,
But it still doesn't work. This is my code
locationEngine->startLocationUpdates(5000);
void LocationEngine::startLocationUpdates(int frequency) {
if (positionSource) {
positionSource->setUpdateInterval(frequency);
positionSource->setPreferredPositioningMethods(
QGeoPositionInfoSource::AllPositioningMethods);
positionSource->setProperty("responseTime", 10000);
positionSource->startUpdates();
qDebug() << "updates started";
}
}
Am I missing something? & also I can't find properties in the documentation. Can you tell me where I can find these?
Regards,
Nishant Shah