[Qt-interest] QWebView::setContent (xxx, "application/pdf") crashes adobe reader 8.* [SOLVED]
Frank Hemer
frank at hemer.org
Wed Jun 16 14:27:34 CEST 2010
Hi all,
interesting: googeling for any combination of 'qt webkit adobe reader crash'
does not produce any usable result ... seems like noone else
uses 'setContent' like me???
However in case someone else stumbles over this issue, I found a workaround:
1. write the data to a tmp file
2. create an html construct and embed the reader:
QString html = QString ("<html>\n"
"<head>\n"
" <script type=\"text/javascript\">\n"
" <!--\n"
" function setWidth (width) {\n"
" document.getElementById (\"PdfReader\").style.width=width;\n"
" }\n"
" function setHeight (height) {\n"
" document.getElementById (\"PdfReader\").style.height=height;\n"
" }\n"
" //-->\n"
" </script>\n"
"</head>"
"<body>\n"
" <object id=\"PdfReader\" name=\"PdfReader\" width=\"%1\"
height=\"%2\"><embed src=\"file:///%3\" type=\"application/x-pdf\"/>\n"
"</object>\n"
"</body>\n"
"</html>")
.arg (width () - 20)
.arg (height () - 20)
.arg (m_tmpFileName);
3. forward resizing of the view via javascript
void MyWebView::resizeEvent (QResizeEvent * e) {
QWebView::resizeEvent (e);
page ()->currentFrame ()->evaluateJavaScript (QString ("setWidth(%1);").arg
(width () - 20));
page ()->currentFrame ()->evaluateJavaScript (QString
("setHeight(%1);").arg (height () - 20));
}
Hope this helps
Frank
More information about the Qt-interest-old
mailing list