It is possible to use geolocation in Desktop applications with QWebView?
I tried set PermissionGrantedByUser, but not work:
Qt Code:
void WebPage::permissionRequested(QWebFrame* frame, Feature feature) { switch (feature) { case Geolocation: qDebug() << "GEO-Location: PermissionGrantedByUser"; setFeaturePermission(frame, feature, PermissionGrantedByUser); break; default: qDebug() << ""; } }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:
I believe that I have to build a library and put in the qtDir/compiler/plugins/positionQt Code:
<script> function displayError(err) { document.getElementById("geo").innerHTML = ("Error Code: " + err.code + " / msg: " + err.message); } function displayLocation(position) { document.getElementById("geo").innerHTML = [ "latitude:" + position.coords.latitude, "longitude:" + position.coords.longitude ].join(", "); } function getMyLocation() { if (navigator.geolocation) { navigator.geolocation.watchPosition(function(a, b, c) { console.log(a, b, c); document.getElementById("geo").innerHTML = "Testando..."; }); navigator.geolocation.getCurrentPosition(displayLocation, displayError, { enableHighAccuracy: false, timeout: 10000, maximumAge: 0 }); } else { document.getElementById("geo").innerHTML = "No geolocation support"; } } window.onload = function() { getMyLocation(); }; </script> <div id="geo"></div>To copy to clipboard, switch view to plain text mode
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" ...
Bookmarks