Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I cant find the current location's city name?

I cant find the current location's city name?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 309 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bladekel
    wrote on last edited by
    #1

    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?

    raven-worxR 1 Reply Last reply
    0
    • B bladekel

      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?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

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

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved