QGeoCoordinate returns Nan



  • Hi!
    I` m trying to implement positioning on Android, but it returns coordinates as "nan";
    Here is the code:

     QString *text = new QString;
    
    
        auto source = QGeoPositionInfoSource::createDefaultSource(this);
        if(source){
        text->append("sourceName: " + source->sourceName()); //return: core location
        source->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods);
        source->setUpdateInterval(1000);
        source->requestUpdate();
    
    
        }
    
        QLabel *lbl = new QLabel;
        QGeoPositionInfo info = source->lastKnownPosition();
        QGeoCoordinate coordinate = info.coordinate();
        auto  latitude = QString::number(coordinate.latitude());
        auto longitude = QString::number(coordinate.longitude());
    
        lbl->setText(*text);
    
        QString all;
        all = latitude;
        all += ",";
        all += longitude;
        //lbl->setText(all);
    
        QString URL("https://www.google.ru/maps/@" + all);
    
        QUrl myUrl(URL);
        QDesktopServices::openUrl(myUrl);
    
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.