Qt webview调用JavaScript 带参函数

void MainWindow::on_pushButtonShowMarker_clicked()
{
     QString lat = "104.701681";
     QString lon = "31.535617";
    //ui->webViewMap->page()->mainFrame().evaluateJavaScript("addMarker()");
   // double w=lat.toDouble();
   // double k=lon.toDouble();
    QString command = QString("addMarker(%1, %2)").arg(lat)//addMarker为JavaScript函数addMarker(lat,lon)
          .arg(lon);
    //ui->webViewMap->page()->mainFrame()->addToJavaScriptWindowObject("jingdu", jingdu);
     qDebug()<<command;
    ui->webViewMap->page()->mainFrame()->evaluateJavaScript(command);

}

 

posted @ 2015-01-05 19:28  CrazyDiode  阅读(1135)  评论(0编辑  收藏  举报