1

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 ?

4

1 回答 1

1

只是保存到磁盘并在 HTML 代码中提供相对路径是一种选择吗?您可以使用QImage::save () 写入磁盘。

编辑:如果您想直接从缓冲区加载,您可以将 QImage 直接用于 HTML 图像:https ://qt-project.org/doc/qt-4.8/qtwebkit-bridge.html#pixmaps-and-images 。

于 2013-05-04T12:47:33.873 回答