Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-82114

QTextDocument ignore underline color

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 6.2.0 Alpha
    • 5.14.1
    • GUI: Text handling
    • None
    • All
    • 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

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            jgirardet Jimmy Gir
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes