Results 1 to 2 of 2

Thread: WebEngineView: image not loaded in a HTML when using 'loadHtml' with HTML content in

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2013
    Posts
    61
    Qt products
    Qt4
    Platforms
    Windows

    Default WebEngineView: image not loaded in a HTML when using 'loadHtml' with HTML content in

    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:

    Qt Code:
    1. WebEngineView {
    2. id: myChat
    3. ...
    4. url: "qrc:/res/test.html"
    5. ...
    6. }
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. <div class="file-thumbnail" style="background-image: url(file:///C:/Users/Diego/AppData/Local/Temp/Penguins.png);"></div>
    To copy to clipboard, switch view to plain text mode 

    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

    Qt Code:
    1. myChat.loadHtml(text);
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. js: Not allowed to load local resource: file:///C:/Users/Diego/AppData/Local/Temp/Penguins.png
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by ddonate; 9th May 2017 at 15:56.

  2. #2
    Join Date
    Apr 2013
    Posts
    61
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: WebEngineView: image not loaded in a HTML when using 'loadHtml' with HTML content

    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

Similar Threads

  1. Replies: 1
    Last Post: 30th October 2015, 03:27
  2. Replies: 1
    Last Post: 19th June 2014, 09:09
  3. Convert Html content into QStandardItemModel
    By nikhilqt in forum Qt Programming
    Replies: 5
    Last Post: 29th February 2012, 20:46
  4. Why the images from the HTML file is not loaded??
    By rleojoseph in forum Qt Programming
    Replies: 8
    Last Post: 2nd March 2011, 11:29

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.