In normal application, the log is import for debug, test or notify the user some information. And I use QT example code to display my mqttclient logs with readOnly QPlainTextEdit.
But in the readOnly mode, you can interaction with the QPlainTextEdit to scroll or copy some text. The problem is that can modify the cursor of the QPlainTextEdit. Then the next insertPlainText will put at the wrong position. If set QPlainTextEdit enable to false. You can't interaction with the QPlainTextEdit to scroll or copy some text.

So I get the QPlainTextEdit textCursor and move to start of document. Then insertPlainText with the log.
But that is no effect and the problem is same.
After read the document of QT QPlainTextEdit::textCursor. I find the note is the textCursor is one new copy. After modify the cursor position should use setTextCursor to update current QPlainTextEdit textCursor.

The code like:
// The bellow code is no affect the QPlainTextEdit editLog.
// ui->editLog->textCursor().setPosition(QTextCursor::Start);
QTextCursor _cursor = ui->editLog->textCursor();
// Absolute position, QTextCursor::Start is 0.
// The setPosition can do same thing.
// _cursor.setPosition(0);
// Use movePosition with enum to move the cursor to document begin and insert log by time descending order.
_cursor.movePosition(QTextCursor::Start);
ui->editLog->setTextCursor(_cursor);
ui->editLog->insertPlainText("log content...");
And the final log viewer look like:

The full project code at codeberg.org qtlearning .