QTextEdit can't insertPlainText after insertHtml. QTextEdit inserts html and then inserts plain text. Plain text is still displayed in html format. Is this a bug? Or am I using the wrong method.
I want to add html first and then plain text, and they will display properly, what do I do.
The documentation is quite clear.
QTextEdit::insertPlainText()
says that:
It is equivalent to
edit->textCursor().
insertText()
Which, in turn, clearly says that:
Inserts text at the current position, using the current character format.
So, follow the simple procedure:
textCursor()
;setCharFormat()
with an empty QTextCharFormat()
instance;setTextCursor()
so that the format is actually applied for new insertions;insertPlainText()
;I strongly recommend you to read the documentation about to the Qt rich text processing and the related topics, such as its structure and classes (starting from QTextDocument and QTextCursor).