Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.14.1
-
None
-
-
688602704d5c5226491b0d0ab7f596f9568966d6 (qt/qtbase/dev)
Description
Hi,
I'm having trouble setting underline color in QTextDocument. I tried using setUnderlineColor or setting css style via insertHtml and it as no effect.
Please look at the code :
from PySide2.QtGui import QTextDocument, QTextCursor, QTextCharFormat, QColor a = QTextDocument() a.setHtml('') c =QTextCursor(a) c.insertText("with setcolorunderline") c.select(QTextCursor.BlockUnderCursor) f = QTextCharFormat() f.setUnderlineColor(QColor("green")) f.setFontUnderline(True) c.setCharFormat(f) c.movePosition(QTextCursor.End) c.insertBlock() c.insertHtml("""<p><span style=" text-decoration: underline red;">with text-decoration overloaded</span></p>""") c.insertBlock() c.insertHtml("""<p><span style=" text-decoration: underline; text-decoration-color: red;">with text-decoration-color</span></p>""") print(a.toHtml()) # everything stripped before and after span # <span style=" text-decoration: underline;">with setUnderlineColor</span> # <span style=" text-decoration: underline;">with text-decoration overloaded</span> # <span style=" text-decoration: underline;">with text-decoration-color</span>
I talked to qtforpython mainainer who told me it doesn't look like a python specific bug.
I can't C++ so I can't give you C++ snippet.
As you can see there nothing about underline color in the result.
maybe it's related to it : https://bugreports.qt.io/browse/QTBUG-39617