0

I'm using QWebView as a rendering layer for my application.

I would like to be able to buffer an image in memory and have the webkit engine render the image progressively as it buffers, like it would over an HTTP connection, by inserting an <img> tag.

A bit of Googling suggests that QWebView can access image content from either a local file, HTTP URL, or a Qt resource URL. My application uses none of these mechanisms, it receives and decodes the image data from a Unix socket stream.

What is the least-messy way I can get a buffered/buffering image to render in a QWebView img tag (e.g. without having to set up a localhost HTTP daemon or save files to disk first)?

  • Please check if this helps http://developer.nokia.com/community/discussion/showthread.php/188112-QWebView-load-page-from-memory – Pratham Oct 17 '14 at 10:49

1 Answers1

3

One solution that came to my mind ..

Create a QByteArray or QBuffer from the data you want to be used as an image, and then use QWebView::setContent() with QByteArray or construct an HTML tag of the data and use QWebView::setHtml().

I haven't tried this hence not sure if it would work.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Pratham
  • 1,522
  • 1
  • 18
  • 33
  • Are you saying I could pump the raw image data directly into an HTML tag within the webview and then assign the raw data to an img tag somehow? I don't understand. – Username Obfuscation Oct 17 '14 at 11:18
  • Yup you can if you have your image as jpg format and raw data is encoded in base64 format. Please check the following link http://stackoverflow.com/questions/22539999/how-to-display-raw-image-data-with-html-and-javascript and http://jsfiddle.net/bYGum/ – Pratham Oct 20 '14 at 06:31