When using myQTextEdit.append() the style of the inserted text is as follows (Qt 5.14 documentation):
"The new paragraph appended will have the same character format and block format as the current paragraph, determined by the position of the cursor."
However I would find it convenient to be able to append text with a neutral style.
What causes my problem is this: I have a log window in the form of a QTextEdit where I append text (mostly neutral but some element may be coloured, etc.). Since it's for log purposes, the QTextEdit is read-only and the text elements are always added at the end (append()). This is fine as long as the user never clicks on the text. When clicking on a part of the QTextEdit, the cursor position is changed. It's not an issue for the position since I use append() which inserts text at the end, even if the cursor is somewhere else. However, if the user clicked on something with a non-neutral style, the afterwards appended text will have this style as well, which is not desirable.
What would be interesting for me would be to either block the cursor so that the user can't tamper with the styles or to append without basing the style on the current paragraph.
Is there a way to change this behaviour, other than by subclassing QTextEdit?
As mentioned, I could check the cursor position before doing any append() (and set the cursor at the end of the document if it has been moved) but if it exists, I would prefer a more "global" solution.