I use the following code to get GeoLocation for my app
QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(this);
if (source) {
source->setUpdateInterval(1000); // time in milliseconds
source->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods);
connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
source->startUpdates();
source->requestUpdate(30000);
const QGeoPositionInfo &info =source->lastKnownPosition();
ui->label->setText(QString("Latitude - %1 Longitude - %2").arg(info.coordinate().latitude()).arg(info.coordinate().longitude()));
}
This code runs perfectly on the Simulator and gives me the coordinates provided by the simulator however this does not work when i try to run it on my N900. It returns Nan instead of the latitude and longitude coordinate. The current GPS signal on the phone is coarse accuracy. Also geolocation is working in the OVI Maps app on the phone. Any idea why the above code is unable to get the geolocation on the phone but works perfectly on the simulator ?