Question

I have the below code

QWebView webView;
QImage img = QImage::fromData((unsigned char *)data, size); // comes from some data source
webView.setHtml("<html><body><img src=\"how_to_load\"/></body></html>");
webView.show();

where I want to load img in the webview.

Any ideas ?

Était-ce utile?

La solution

Is simply saving to disk and providing the relative path in the HTML code an option? You can use QImage::save() to write to disk.

EDIT: If you want to load directly from the buffer you can use QImage directly into HTML images: https://qt-project.org/doc/qt-4.8/qtwebkit-bridge.html#pixmaps-and-images.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top