Мне нужно добавить текст в QPlainTextEdit
без добавления в текст новой строки, но оба метода appendPlainText()
и appendHtml()
добавляют фактически новый абзац.
Я могу сделать это вручную с помощью QTextCursor
:
QTextCursor text_cursor = QTextCursor(my_plain_text_edit->document());
text_cursor.movePosition(QTextCursor::End);
text_cursor.insertText("string to append. ");
Это работает, но мне также нужно держать свиток внизу, если он был внизу до добавления.
Я попытался скопировать логику из источников Qt, но я застрял на ней, потому что там используется класс QPlainTextEditPrivate
, и я не могу найти способ сделать то же самое без него: скажем, я не вижу метод verticalOffset()
в QPlainTextEdit
.
На самом деле, эти источники содержат много странных (по крайней мере, первого взгляда) вещей, и я не знаю, как это реализовать.
Здесь исходный код append()
: http://code.qt.io/cgit/qt/qt.git/tree/src/gui/widgets/qplaintextedit.cpp#n2763