Nominate our 2022 Qt Champions!

QT and Google Maps API 3

  • Hello everybody,

    I want to use googlemap api 3 to display a simple map under an UI developped in QT. For that purpose, I use a Qwebview which load a javascript code as an url. My code works with google api v2 but doesn't display anything with googlemaps api 3. Moreover, when using the javascipt code loaded in a chrome browser, it works fine. Here is the code html :
    @<HTML >
    <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">



    function load() {

    var optionsCarte = {zoom: 12,center: new google.maps.LatLng(44.843056, -0.644722),mapTypeId: google.maps.MapTypeId.ROADMAP};
    var map = new google.maps.Map(document.getElementById("mapdiv"), optionsCarte);

    <META content="MSHTML 6.00.2900.5848" name=GENERATOR>

    <BODY leftMargin=0 topMargin=0 onload=load() onunload=GUnload() >

    <DIV id="mapdiv" ></DIV></BODY></HTML>@

    This code is loaded with the following instructions in QT:
    @ui->webView->setUrl( url );@

    Note that the signal loadFinished of the QwebView returns a false flag.

    Anyone can help me ?


  • Can you provide a complete and valid html-page? Delete your personal or confidential stuff, but it must be at least usable to recreate the problem.

  • Mmmh. I don't understand why the html code is cut...
    Here are the lines not removed (sorry for that problem) before the load function (with the character '<' and '>' correctly set) :

    script type="text/javascript" src=""/script>
    SCRIPT type=text/javascript

    and after the load function (with the character '<' and '>' correctly set):


    I hope it is clear... not sure...

  • you forgot the ";" (semicolon) behind onload() and GUnload(), maybe QtWebKit is a bit more strict here? write:
    @<BODY onload=load(); onunload=GUnload(); >@

  • Thank you.
    but still doesn't work...

Log in to reply