Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. QWebView and geolocation.getCurrentPosition?
QtWS25 Last Chance

QWebView and geolocation.getCurrentPosition?

Scheduled Pinned Locked Moved Qt WebKit
linuxwindowsmacqtwebkitgeolocationqtpositioningqgeocoordinate
1 Posts 1 Posters 1.3k Views
  • 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
    brcontainer
    wrote on last edited by brcontainer
    #1

    It is possible to use geolocation in Desktop applications with QWebView?

    I tried set PermissionGrantedByUser, but not work:

    void WebPage::permissionRequested(QWebFrame* frame, QWebPage::Feature feature)
    {
        setFeaturePermission(frame, feature, PermissionGrantedByUser);
    }
    
    • I tried add this QT += positioning, but not work
    • I tried add this TARGET.CAPABILITY += NetworkServices Location, but not work, I believe this is for smartphones, like symbian.

    Event displayLocation is never fired:

    <script>
    function getMyLocation() {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(displayLocation);
        } else {
            alert("No geolocation support");
        }
    }
    
    function displayLocation(position) {
        document.getElementById("geo").innerHTML = [
            "latitude:" + position.coords.latitude,
            "longitude:" + position.coords.longitude
        ].join(", ");
    }
    
    window.onload = function() {
        getMyLocation();
    };
    </script>
    <div id="geo"></div>
    

    I believe that I have to build a library and put in the qtDir/compiler/plugins/geoservices, but do not know where to start or if I have to use lib qtgeoservices_nokia or qtgeoservices_osm

    How can I do this?

    Or is it possible to customize the event and send coordinates of a 3rdparty lib (I'm not asking for a library and I'm not asking for alternatives in javascript) in response to the navigator.geolocation.getCurrentPosition?


    Extra info about

    If use QT_DEBUG_PLUGINS=1 in debug mode Application Output return this (note that the first line is generated by WebPage::permissionRequested):

    GEO-Location: PermissionGrantedByUser
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Qt5.4.0/5.4/mingw491_32/plugins/position" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt5.4.0/5.4/mingw491_32/plugins/position/qtposition_positionpoll.dll"
    Found metadata in lib C:/Qt5.4.0/5.4/mingw491_32/plugins/position/qtposition_positionpoll.dll, metadata=
    {
        "IID": "org.qt-project.qt.position.sourcefactory/5.0",
        "MetaData": {
            "Keys": [
                "positionpoll"
            ],
            "Monitor": true,
            "Position": false,
            "Priority": 1000,
            "Provider": "positionpoll",
            "Satellite": false
        },
        "className": "QGeoPositionInfoSourceFactoryPoll",
        "debug": false,
        "version": 328704
    }
    
    
    "The plugin 'C:/Qt5.4.0/5.4/mingw491_32/plugins/position/qtposition_positionpoll.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
             not a plugin
    QFactoryLoader::QFactoryLoader() looking at "C:/Qt5.4.0/5.4/mingw491_32/plugins/position/qtposition_positionpolld.dll"
    Found metadata in lib C:/Qt5.4.0/5.4/mingw491_32/plugins/position/qtposition_positionpolld.dll, metadata=
    {
        "IID": "org.qt-project.qt.position.sourcefactory/5.0",
        "MetaData": {
            "Keys": [
                "positionpoll"
            ],
            "Monitor": true,
            "Position": false,
            "Priority": 1000,
            "Provider": "positionpoll",
            "Satellite": false
        },
        "className": "QGeoPositionInfoSourceFactoryPoll",
        "debug": true,
        "version": 328704
    }
    
    
    Got keys from plugin meta data ("positionpoll")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/projects/webview-example/debug/position" ...
    

    QT project: https://github.com/brcontainer/qt-helper

    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