views:

43

answers:

1

I have a QWebView in my app which renders a html page stored in the app as a Qresource. This page, however requires meaty external Javascript libraries such as MathJax, which I would want to include as a resource due to its size.

My problem is that it seems that QtWebkit does not cache these files as a regular browser would do, and every time I refresh the widget it downloads MathJax afresh.

So my question is: is there any way to cache these libraries after first time they are downloaded, without having resorting to shipping it with the app as resource?

A: 

Could you post some source code? Once downloaded that data will stay in the /tmp/ folder for some time. You could likely use the data in the temp folder, my guess is you are not enforcing that policy.

Prof.Ebral
Well the code is as plain as it can be, the widget is defined like this:: self.modelWebView = QtWebKit.QWebView(self.scrollAreaWidgetContents_2)and it loads a html document which loads some external jsUsing the data in /tmp/may not be a good idea since on other platforms (e.g. windows) the data may end up elsewhere.
fccoelho
sorry .. I should have said the (temp) directory, or said it some other way to imply I meant it as the temp folder regardless of OS. <br /><br />Because you are working from the basic class you will need to redefine how it it operates. One way to go about doing this is to turn all of your web pages into QWebElements before you navigate to them. The first time you load the page you can extract the script, save it as an object, and then re use it's contents from memory, inserting the script and local location as an element.
Prof.Ebral
I wanted to add a second comment since I ran out of characters. The process is pretty simple and you can do it how you want. You download the script's source and create an object with it's contents and then use that locally. That is what I would suggest.
Prof.Ebral