Quantcast
Channel: Qt DevNet forums: Qt WebKit
Viewing all articles
Browse latest Browse all 542

QWebView: strange problem with embedded images

$
0
0
Hi there! I’m faced by very strange problem. I need to convert generated HTML-code into image. For that I use such code: QPixmap img(imgWidth, imgHeight); QPainter painter(&img); painter.fillRect(img.rect(), Qt::white); QBrush br(Qt::white); QPen pn(Qt::black); painter.setBackground(br); painter.setPen(pn);   QWebView webView; webView.setGeometry(0, 0, imgWidth, imgHeight);   webView.setHtml(content); // content - is given HTML-code webView.page()->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); webView.page()->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);   webView.page()->mainFrame()->render(&painter); And it works fine …but. This HTML-code contains such content: <img src="data:image/png;base64, ..." /> and this image is not displayed. For debugging reasons I created a window with QLabel and QWebView. QLabel is used to show pixmap, generated by the code, presented above. QWebView displays the content, used to generate the image. In other words, I use this window to compare the image, generated by my code, and the representation of the same HTML code by QWebView widget. I use two different buttons to update the pixmap in QLabel and to set the content in QWebView widget. I found out very strange thing. When I press the first button, the QLabel displays the correct pixmap, but without embedded image. When I press the second button, QWebView displays the correct result with embeded image. If after that I press the first button again, the QLabel widget displays the pixmap with enbedded image. In other words, QLabel displays correct pixmap with embedded image only if QWebView already displayed the same content earlier. It seems, QWebView activats something, what allows QWebView, used in my code (see above), to display the embedded image. Any ideas? Thank you in advance. P.S. I use Qt v4.7.4. Windows 7 x64 MinGW 4.4.0

Viewing all articles
Browse latest Browse all 542

Trending Articles