PDA

View Full Version : External resources and QWebView::setHtml



anoraxis
27th March 2012, 23:00
Hi, I have an XSL file that I use to transform some XML files and view it on a QWebView. This is my code:

QFile tpl(":/template.xsl");
tpl.open(QIODevice::ReadOnly);
QString tplString = tpl.readAll().constData();
tpl.close();

QString resultHtml;
QXmlQuery query(QXmlQuery::XSLT20);
query.setFocus(QUrl(qApp->applicationDirPath() + QDir::separator() + "database.xml"));
query.setQuery(tplString);
query.evaluateTo(resultHtml);

webview->setHtml(resultHtml, qApp->applicationDirPath());

The XSL file refers to some external resources like a *.css and some scripts. I pass the resulting html to the QWebView with setHtml(QString text, QUrl baseUrl). The html structure is correctly visualized on the webview but none of the external resources. The docs of QWebView says that the external resources are loaded based on baseUrl. After the call to QWebView::setHtml() I try

qDebug() << webview->page()->mainframe()->baseUrl()

and the result is "".

When I transform this XML with this XSL on another web browser it works right. What could be the problem here?