QTextEdit/QTextBrowser两个控件追加文本的接口使用方法都是一样的。
以QTextBrowser为例:
1.追加文本自动换行:
textBrowser->append("hello ");
textBrowser->append("world");
append接口会自动换行,所以会在文本框中打印:
hello
world
2.追加文本不自动换行
textBrowser->insertPlainText("hello ");
textBrowser->insertPlainText("world");
insertPlainText接口是在当前光标插入文本(光标一般默认在末尾),不自动换行,所以会打印:
hello world