Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in
read-only mode
.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
I want to change the color of font basing on the user input.
More precisely, if a user gives a certain word, I want only this word to be red and leave the rest of text with the same color.
I was thinking to interpret every given character and if the pattern matches, do the following:
# to move the cursor to the beginning of given input pattern
self.textEdit.moveCursor(QTextCursor.End - 3)
responseStyle = "<span style=\" color:" + RESPONSE_COLOR + ";\" >"
# change the style
self.textEdit.insertHtml(responseStyle)
self.textEdit.moveCursor(QTextCursor.End)
# end the changed style section
self.textEdit.insertHtml("</span>")
However, the color doesn't change.
Does anyone have an idea how to solve it?