Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

I cant find the current location's city name?



  • I need to find the city name of the that my app runs.

    I can find the coordinates but couldnt find the city name.

    Here is what I have tried;

    QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(this);
    if (source) {
        connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)),
                this, SLOT(positionUpdated(QGeoPositionInfo)));
        source->startUpdates();
    }
    
    void positionUpdated(const QGeoPositionInfo &info)
    {
        qDebug() << "Position updated:" << info;
    }
    

    With these lines I can clearly get the latitude and the longitude of my PC's position.

    I need city name but how?


  • Moderators

    @bladekel
    in QML you would use the GeocodeModel type for this.
    You can check what the C++ code is doing.


Log in to reply