tags:

views:

160

answers:

0

Hi,

I want to develop an application that uses QtWebKit and JQuery.

What I need to know is, is there any difference between reading JQuery from a file and evaluateJavaScript it, or embedding it as a script tag within the "page" that is displayed within the widget?

EDIT: It seems that I have this figured out at least partially. evaluateJavaScript will apparently work reliably; but if I do

baseurl = QUrl.fromLocalFile(
  QDir.current().absoluteFilePath("doesntexist.html"));
view.setHtml(
  u"""
    <html>
      <head>
        <script type="text/javascript" 
          src="jquery-1.4.2.js">
        </script>
      </head>
      <body></body>
    </html>""", baseurl);

The file is never even read from disk (checked with inotify). this also affects baseurl being initialized with either

QUrl("file:/")
QUrl(".");
QUrl();

or

QUrl("file://")

And I have also tried to change the script src parameter to absolute paths on the hard drive, and to a relative path with and without "./" in front.

How do I do it right (aside from the Qt Resource System) to get the script tag to work with local js files? Is this just poorly documented, or am I missing something?