Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
None
-
5.2.0, 5.2.1
-
None
-
Custom compiled Qt 5.2.0 and 5.2.1 on Mac OS X 10.9.1. I did not try to reproduce this problem on other platforms.
Description
When a webpage displayed by QML WebView has references to application resources (qrc:*), they work correctly only if the page is loaded using url property and not loadHtml() method.
Sample program is attached and also available for convenient online browsing at https://gist.github.com/msiedlarek/8824547
When loaded using url attribute, the webpage is displayed correctly and attached script is readable by the engine, as seen in the Inspector (success.png):
But when the same HTML code is loaded using loadHtml method, the result is quite different (failure.png):
I have tried tracing the problem in the QtWebKit source, but achieved nothing, probably knowing too little about its inner workings. It would be great if someone could shed some light on what's going on here.
Edit 1
Adding explicit charset="utf-8" to the script tag did it. Am I correct to assume that when the HTML is loaded from UTF-16 QString, the encoding of external scripts and stylesheet is expected to be UTF-16?
This surprises me, because I used QWebView::setHtml() previously and it assumes (and mentions it in the docs) that external resources are UTF-8.
So it's up to you to decide whether this is a bug or a lack of documentation.