사용자가 Google지도에서 위치를 선택할 수있는 Qt 프로그램이 있습니다. 나는 QWebView 컨트롤에서이 파일을지도를 생성하고로드에 대한 간단한 HTML 파일을 사용하고 있습니다 :Qt QWebView 및 JavaScript에서 데이터 전달
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html
{
height: 100%;
}
body
{
height: 100%;
margin: 0;
padding: 0;
}
#map_canvas
{
height: 100%;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
google.maps.event.addListener(map, "click", function (event) {
var geoLocationUrl = 'http://maps.googleapis.com/maps/api/geocode/xml?latlng='
+ event.latLng.lat() + "," + event.latLng.lng() + "&sensor=false";
console.log(geoLocationUrl);
$.ajax({
type: "GET",
url: geoLocationUrl,
dataType: "xml",
success: function (xml) {
},
error: function() {
}
});
});
}
function showLocation(location) {
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width: 100%; height: 100%">
</div>
</body>
</html>
문제는 Qt는 C++ 코드 아약스 요청 후 데이터를 전달하는 방법이다. Qt C++에서 자바 스크립트 함수를 평가할 수 있다는 것을 알고 있지만이 경우 작업이 반대입니다.
내가 여기에 자바 스크립트로 C++ 방법에서 데이터를 전달할 수있는 방법 :
은 꽤 잘하는 과정을 설명하는 질문을 발견했다. 콜백을 의미합니다. 이 질문에 대답 해주세요 - http://stackoverflow.com/questions/22006667/in-qtwebkit-how-to-install-the-callback-from-c-to-javaobject-window –