Display webpage using the source code from a QByteArray
-
I have a QByteArray which contains the source code of a website.
I want to display, in my application, the website ( like emulating a browser ), but i want to use the source code from my QByteArray.
-
So? Decode the bytes into a string and use QWebView::setHtml.
-
@
myWebView->setHtml( QString::fromLatin1( byteArray ) );
@assuming that your QByteArray contains latin1 encoded data.
-
Normally, the encoding would be somewhere in the first part of the HTML header. You might need to search for that header, and re-parse the document based on what you find. You can not just assume that it is one encoding or the other. Normally, you'd find the encoding information (also) in the HTTP headers, but I gather that you don't have those?
-
You should try "QWebView::setContent() ":http://doc.qt.nokia.com/4.7/qwebview.html#setContent, it takes a QByteArray as argument.
-
[quote author="Volker" date="1304374840"]You should try "QWebView::setContent() ":http://doc.qt.nokia.com/4.7/qwebview.html#setContent, it taks a QByteArray as argument.[/quote]
Even better, of course :-)