How to append text in a QTextBrowser in QT?

此生再无相见时 提交于 2020-01-14 10:16:12

问题


I have created a QTextBrowser to display a large amount of data (actually displaying the run time log), which is dynamically generated in another processes.

I have found out that I can use fopen("log.html","a") to append data to an actually log file, and reload() it every time it's updated, but I think that's not efficient, or even possibly unwise.

I wonder if there's a neat way to implement this.


回答1:


Got half way through writing this, supplemental to TonyK's answer:

Perhaps the append Method is what you're looking for?

Appends a new paragraph with text to the end of the text edit. The new paragraph appended will have the same character format and block format as the current paragraph, determined by the position of the cursor. See also currentCharFormat() and QTextCursor::blockFormat().




回答2:


QTextBrowser inherits QTextEdit, so you can use QTextEdit::append:

void QTextEdit::append ( const QString & text )


来源:https://stackoverflow.com/questions/8846691/how-to-append-text-in-a-qtextbrowser-in-qt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!