Qt: Mobility GeoLocation works on Simulator, but not on N900

I use the following code to get GeoLocation for my application

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 works fine on Simulator and gives me the coordinates provided by the simulator, however it does not work when I try to run it on my N900. It returns Nan instead of the latitude and longitude coordinates. The current GPS signal on the phone is brute precision. Also, geolocation works in the OVI Maps application by phone. Any idea why the above code cannot get geolocation on the phone, but works fine on the simulator?

+3
source share
1 answer

positionUpdated(), . requestUpdate() positionUpdated(). - , requestTimeout(), , , . , lastKnownPosition(), , . , , , requestUpdate() , , , source->lastKnownPosition.isValid(), , .

positionUpdated() , . , .

positionUpdated() ?

+2

Source: https://habr.com/ru/post/1765588/


All Articles