Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.7.0
-
None
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.