Search code examples
pythonpysideqwebpage

Using QWebFrame.setContent() with unicode (Python+PySide)


I'm using QWebKit to render a a pdf-page. Untill now, I used setHtml(), to feed the html code to the QMainFrame and then render() to print the content or export it to pdf. So far so good, but I want to use setContent() to include inline-svg-images to the frame, which get not displayed, using setHtml().

But setContent() only accepts QByteArray, and the html-Code is in unicode. How do I feed the unicode string to setContent()?


Solution

  • The way to get a byte array out of a unicode is to encode it.