I'm trying to experiment with the QWebView widget and having trouble getting to grips with the
settings.setUserStyleSheetUrl option.
With this simple example:
Code:
self.webview = QWebView()
self.webview.setHtml(u'<body><p>This is a simple test</p></body>')
self.webview.settings().setUserStyleSheetUrl(QUrl(u'p {color:red;}'))
The html text displays OK in the widget, but the css is not used. So I'm obviously missing something basic. Please can anyone enlighten me?
Edit: Nevermind, I think I finally figured it out

This seems to work:
Code:
from base64 import b64encode
self.webview = QWebView()
self.webview.setHtml(u'<body><p>This is a simple test</p></body>')
self.webview.settings().setUserStyleSheetUrl(QUrl("data:text/css;charset=utf-8;base64," + b64encode('body {color: red}'.encode('utf-8'))))