我在我的C++ GUI应用程序中使用QTextEdit,我使用textEdit-> append(byteArray); 添加一些文本,不幸的是append()在每次调用append()后在最后添加一个新行字符.我知道我可以使用insertPlainText(),它不会添加新行字符,但在处理大文档时会占用更多内存.
谢谢你的帮助!
自从文档QTextEdit::insertPlainText说
它相当于
Run Code Online (Sandbox Code Playgroud)edit->textCursor().insertText(text);
我会假设你可以做类似的事情
edit->textCursor().deletePreviousChar();
Run Code Online (Sandbox Code Playgroud)
如果需要,您可以先清除任何选择
edit->textCursor().clearSelection();
Run Code Online (Sandbox Code Playgroud)