6

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.

Mat
  • 202,337
  • 40
  • 393
  • 406
iloahz
  • 4,491
  • 8
  • 23
  • 31
  • If you need a more performant version of append, you need to [access the internal QTextDocument](https://stackoverflow.com/questions/54501745/performantly-appending-rich-text-to-qtextedit-or-qtextbrowser-in-qt/54501760#54501760). – savolai ᯓ Feb 03 '19 at 10:02

2 Answers2

26

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

void QTextEdit::append ( const QString & text )
jpyams
  • 4,030
  • 9
  • 41
  • 66
TonyK
  • 16,761
  • 4
  • 37
  • 72
  • Thank you all the same! however i don't know how to choose multiple answers – iloahz Jan 13 '12 at 06:56
  • 1
    @Topro: There can be only one accepted answer (with the green tick), but you can upvote as many answers as you like. To do so, you must click the little triangle pointing upward on the left of the answer. Similarly, if you think an answer is wrong or does not provide any useful information, you can downvote it with the triangle pointing downward. – Luc Touraille Jan 13 '12 at 08:57
10

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().

Liam M
  • 5,306
  • 4
  • 39
  • 55