Search code examples
qtgeolocationqtwebengine

QWebEngineView giving wrong geolocation coordinates


With the following code:

#include <QApplication>
#include <QWebEngineView>
#include <QWebEngineProfile>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWebEngineView w;
    QObject::connect(w.page(), &QWebEnginePage::featurePermissionRequested, [&](const QUrl &securityOrigin, QWebEnginePage::Feature feature)
    {
        w.page()->setFeaturePermission(securityOrigin, feature, QWebEnginePage::PermissionGrantedByUser);
    });
    w.setUrl(QUrl("https://mycurrentlocation.net/"));
    w.show();
    return a.exec();
}

and a USB dongle connected to my 64bit Archlinux system (with geoclue2 installed and working), I don't get the correct geolocation coordinates (which I get on the same website with Google Chrome).

There are both in France but 200km apart.

Update 1: A similar issue with the same coordinates seems to appear when centering on my position with a QML Map componenent.

Do I need to setup something in order for it to work ?


Solution

  • The issue is not Qt related.

    /usr/lib/geoclue-2.0/demos/where-am-i
    

    returns wrong coordinates.