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