Qt 5.6 WebEngine / QWebEngineView not working anymore (works fine with Qt 5.5)



  • Hi,

    with Qt .5.5.x the code below worked fine when putting it into a QWebEngineView with setHtml(...).

    <html>
    <head>
        <script type="text/javascript" src="http://www.google.com/jsapi?autoload={'modules':[{name:'maps',version:3,other_params:'sensor=false'}]}"></script>
        <script type="text/javascript">
    
            function initialize() {
                var latlng = new google.maps.LatLng(52.12,8.23);
    
                var myOptions = {
                    zoom: 13,
                    center: latlng,
                    mapTypeId: google.maps.MapTypeId.SATELLITE,
                    mapTypeControlOptions: {
                        style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
                    },
                        navigationControlOptions: {
                            style: google.maps.NavigationControlStyle.ZOOM_PAN
                    },
                    scaleControl: true
                    };
    
                var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
                var distanceWidget = new DistanceWidget(map);
            }
    
            function DistanceWidget(map) {
                    this.set('map', map);
                    this.set('position', map.getCenter());
                    var marker = new google.maps.Marker({
                    draggable: true,
                    title: 'Move me!'
                });
    
                google.maps.event.addListener(marker, 'drag', function(event){
                       document.getElementById("markerLat").value = event.latLng.lat();
                       document.getElementById("markerLon").value = event.latLng.lng();
                });
    
    
                marker.bindTo('map', this);
    
                marker.bindTo('position', this);
            }
    
            DistanceWidget.prototype = new google.maps.MVCObject();
    
        </script>
    </head>
    
    <body onload="initialize()">
        <input id="markerLat" type="hidden">
        <input id="markerLon" type="hidden">
        <div id="map_canvas" style="width: 100%; height: 100%"></div>
    </body>
    </html>
    
    

    After switching the same code to Qt 5.6.x i always get the following js error:

    js: Uncaught ReferenceError: google is not defined
    js: Uncaught TypeError: Cannot read property 'value' of null

    Any ideas what happened here?

    Greetings

    Nando



  • I had the same question as you,I think ,maybe your project is short of the '.js' file.
    You can add the '.js' file to the project-resource , then have a try.

    By the way ,In my project , It has the ',js' file,but there is still a quetion.
    In my projtct,I want load a HTML that use google maps api and show maps offline ,oc course I have doemloaded the map titles .the HTML can work in any browser, such as chrome, IE ,firefox and so on,but the html doesnot work in Qt5.6.0 which I use the QWebEngineWidget class.
    The error is :
    js: Uncaught TypeError:google.maps.LatLng is not a function
    js: Uncaught TypeError:google.maps.MAP is not a function

    So,this is my question,I haven't solved。


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.