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. Can I get user location on a Qt Desktop application?

Can I get user location on a Qt Desktop application?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 647 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.
  • K Offline
    K Offline
    KelvinSP
    wrote on last edited by KelvinSP
    #1

    I read that the OS X can get the approximate user location using the Wi-Fi network.

    Can I get the approximate user location on a Qt Desktop application?

    I tried to add Qt += positioning to my .pro file and use the following code:

        QGeoPositionInfoSource *source1 = QGeoPositionInfoSource::createDefaultSource(this);
    
        if (source1)
        {
            qDebug() << "Test1";
        }
    
        QGeoAreaMonitorSource *source2 = QGeoAreaMonitorSource::createDefaultSource(this);
    
        if (source2)
        {
            qDebug() << "Test2";
        }
    
        QGeoSatelliteInfoSource *source3 = QGeoSatelliteInfoSource::createDefaultSource(this);
    
        if (source3)
        {
            qDebug() << "Test3";
        }
    

    But no source (source1, source2, source3) is valid.

    Basically, I need to get the user location (latitude and longitude) to calculate the sunrise and sunset time.

    Note 1: the application will run on Windows and OS X.

    Note 2: I'm currently running it on a Macbook Pro with internet connection (don't know if it matters).

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should start by running one of the example from the module.

      IIRC, on macOS you should get a dialog asking whether you allow the application to get the position information from your machine.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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