[Qt-interest] How to call javascript function from qt

宋时跃 song422 at gmail.com
Wed Jun 9 08:30:44 CEST 2010


hi friends:

How can I call javascript function from qt?

This way can do that:
 view->page()->mainFrame()->evaluateJavaScript(
QObject::tr("jsFunction('time out!')"));
but I can't use it! because I don't know js function name in qt code.

This is my case:
test.html:
<html>
        <script language="JavaScript" type="text/javascript">
              function jsFunction(values)       //this function will be
called from qt codes
              {
                    alert(values);
              }

               function test()
               {
                      myObject.set_callback_function( jsFunction ); //this
function will call qt codes,when click button
               }
                </script>
        <body>
             <div id="dest"></div>
             <form action="" method="post">
             <input type="button" name="" value="myTest" onclick="test()" />
             </form>
         </body>
</html>

jsFunction likes a callback function.
How can I do that?
thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100609/638754b5/attachment.html 


More information about the Qt-interest-old mailing list