PDA

View Full Version : WebEngineView: image not loaded in a HTML when using 'loadHtml' with HTML content in



ddonate
9th May 2017, 15:50
Hi,

I am using a WebEngineView to show messages (like a chat), with the help of a WebChannel.

I set a html from resources as url of the WebEngineView:


WebEngineView {
id: myChat
...
url: "qrc:/res/test.html"
...
}

To display an image in my html, i add a 'div', for instance:


<div class="file-thumbnail" style="background-image: url(file:///C:/Users/Diego/AppData/Local/Temp/Penguins.png);"></div>

The thumb is displayed properly, since the file is available in this path

In one moment, i save all the html content into a string and restore it after a while using


myChat.loadHtml(text);

The html content is displayed properly except for the image, an error message appears in console:


js: Not allowed to load local resource: file:///C:/Users/Diego/AppData/Local/Temp/Penguins.png

The image is still there, if I set this link in a real Chrome browser the image is open properly

Any idea? Thanks a lot in advance,

Diego

ddonate
11th May 2017, 09:10
I found it. It seems to be a problem with the WebEngineView class and web security.

I had to add an argument to my QApplication a new argument: "--disable-web-security"

Now it works.

Diego