fifth
11th January 2015, 12:41
Hi, I'm having a problem getting QTextEdit to render a colored font which is preceded by whitespace. It renders with the appearance of each whitespace character overwriting other characters in the string. An example of the problem is ...
import sys
from PyQt5.QtWidgets import QApplication, QTextEdit
app = QApplication(sys.argv)
editor = QTextEdit()
editor.insertHtml(' <font color="Red">HELP</font> <br>')
editor.insertHtml(' <font color="Red">HELP</font> <br>')
editor.insertHtml(' <font color="Red">HELP</font> <br>')
editor.insertHtml(' <font color="Red">HELP</font> <br>')
editor.show()
app.exec_()
I would expect to get output of ...
HELP
HELP
HELP
HELP
But the actual visible output is ...
HELP
HEL
HE
H
Removing the trailing does render the output as expected but is required in the real code for formatting.
Any advice to get this working would be much appreciated.
import sys
from PyQt5.QtWidgets import QApplication, QTextEdit
app = QApplication(sys.argv)
editor = QTextEdit()
editor.insertHtml(' <font color="Red">HELP</font> <br>')
editor.insertHtml(' <font color="Red">HELP</font> <br>')
editor.insertHtml(' <font color="Red">HELP</font> <br>')
editor.insertHtml(' <font color="Red">HELP</font> <br>')
editor.show()
app.exec_()
I would expect to get output of ...
HELP
HELP
HELP
HELP
But the actual visible output is ...
HELP
HEL
HE
H
Removing the trailing does render the output as expected but is required in the real code for formatting.
Any advice to get this working would be much appreciated.