Results 1 to 2 of 2

Thread: How to use QtWebkit with geolocation?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question How to use QtWebkit with geolocation?

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

    I tried set PermissionGrantedByUser, but not work:

    Qt Code:
    1. void WebPage::permissionRequested(QWebFrame* frame, Feature feature)
    2. {
    3. switch (feature) {
    4. case Geolocation:
    5. qDebug() << "GEO-Location: PermissionGrantedByUser";
    6. setFeaturePermission(frame, feature, PermissionGrantedByUser);
    7. break;
    8. default:
    9. qDebug() << "";
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 
    • 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 and watchPosition are never fired and using {timeout: ...} it shows the message Timeout expired:

    Qt Code:
    1. <script>
    2. function displayError(err) {
    3. document.getElementById("geo").innerHTML = ("Error Code: " + err.code +
    4. " / msg: " + err.message);
    5. }
    6.  
    7. function displayLocation(position) {
    8. document.getElementById("geo").innerHTML = [
    9. "latitude:" + position.coords.latitude,
    10. "longitude:" + position.coords.longitude
    11. ].join(", ");
    12. }
    13.  
    14. function getMyLocation() {
    15. if (navigator.geolocation) {
    16. navigator.geolocation.watchPosition(function(a, b, c) {
    17. console.log(a, b, c);
    18. document.getElementById("geo").innerHTML = "Testando...";
    19. });
    20. navigator.geolocation.getCurrentPosition(displayLocation, displayError, {
    21. enableHighAccuracy: false,
    22. timeout: 10000,
    23. maximumAge: 0
    24. });
    25. } else {
    26. document.getElementById("geo").innerHTML = "No geolocation support";
    27. }
    28. }
    29.  
    30. window.onload = function() {
    31. getMyLocation();
    32. };
    33. </script>
    34. <div id="geo"></div>
    To copy to clipboard, switch view to plain text mode 
    I believe that I have to build a library and put in the qtDir/compiler/plugins/position

    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" ...

  2. #2
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use QtWebkit with geolocation?

    Any idea how to do this?

Similar Threads

  1. QtWebkit in Qt5.2
    By mythili in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2014, 06:58
  2. Qtwebkit in qt 4.3
    By raj_iv in forum Qt Programming
    Replies: 0
    Last Post: 7th February 2013, 07:49
  3. Replies: 0
    Last Post: 29th February 2012, 10:48
  4. QtWebKit Tutorials
    By abhisheksood in forum Newbie
    Replies: 0
    Last Post: 2nd September 2010, 17:27
  5. where is QtWebKit.lib?
    By richardander in forum Installation and Deployment
    Replies: 8
    Last Post: 8th April 2009, 17:50

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.