[PySide] override font colour in QWebView

Frank Rueter | OHUfx frank at ohufx.com
Sat May 14 04:47:40 CEST 2016


Hi all,

I have a QWebView displaying some html that I download from an external 
site and I need to change the text colour, because the style inherited 
from the host application renders the html with black text on a dark 
grey background.

This is my simple test snippet that produces the problem inside the 
intended host app:

    from PySide import QtWebKit, QtCore

    w = QtWebKit.QWebView() html = """<p>v1.4: fixed non-uniform
    scale</p> <p> <hr /> v1.3: re-implemented the skew parameters</p>
    <hr /> """

    w.setHtml(html)

    w.show()

I tried using css on the fly as described here, 
<https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/PySide/QtWebKit/QWebSettings.html#PySide.QtWebKit.PySide.QtWebKit.QWebSettings.setUserStyleSheetUrl> 
but to no avail:

    # sets backgroudn colour - just to test if it works at all

    css =
    'data:text/css;charset=utf-8;base64,cCB7IGJhY2tncm91bmQtY29sb3I6IHJlZCB9Ow=='


    w.settings().setUserStyleSheetUrl(css)

I also tried messing with the widgets palette but couldn't get it to work.
I am trying to avoid modifying the html string to include colour 
instructions but currently that seems to be the easiest option.

Any advice out there?

Cheers,
frank


-- 
ohufxLogo 50x50 <http://www.ohufx.com> 	

*vfx for storytellers <http://www.ohufx.com>*

*vfx compositing <http://ohufx.com/index.php/vfx-compositing> | 
*workflow customisation & consulting 
<http://ohufx.com/index.php/vfx-customising>**

*W E L L I N G T O N    |    N E W   Z E A L A N D *

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20160514/c1618a7e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ohufxLogo_50x50.png
Type: image/png
Size: 2666 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20160514/c1618a7e/attachment.png>


More information about the PySide mailing list