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

QTextEdit renders image inside list instead of outside

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7.0
    • GUI: Text handling
    • None
    • Linux/X11

    Description

      When you set the HTML of a QTextEdit, more exactly when you have an image after an unordered list like so:

      auto edit = new QTextEdit(); edit->setHtml("<ul><li>1</li><li>2</li><li>3</li></ul><img src=\"~/.image.png\">");    

       
      the image is appended to the last list element.
      The output of `edit->toHtml();` is
       

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
      <html><head><meta name="qrichtext" content="1" /><style type="text/css">
      p, li { white-space: pre-wrap; }
      </style></head><body style=" font-family:'Fira Sans'; font-size:11pt; font-weight:200; font-style:normal;">
      <ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">1</li>
      <li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">2</li>
      <li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">3<img src="~/.image.png" /></li></ul></body></html>
      
       

      As you can see the image tag now is considered part of the last list element.
      But if between the `</ul>` and '<img' there is at least one non-white character or even a `<br>` tag the HTML is rendered correctly.
       

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            trial97 trial97
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes