Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt's best way to display very large rich text?

Tags:

c++

linux

qt

qt4

I need to display very large logs that uses HTML tags for marking different types of data.

Using QTextEdit and QTextBrowser really slows the application, especially on append operations. I would really like to keep the QTextEdit interface and abilities.

I've seen people that implemented their own flavor of TextEdit to improve performance, but I wandered if anyone solved this issue using "Qt" tools. I thought about using the Model/View framework to load data on demand but it is not quite what it was intended for I think.

Maybe subclassing QTextEdit and override some of its slots for scrolling...

If anyone encountered this issue and solved it, I would appreciate some tips.

Thanks.

like image 243
Benjamin K. Avatar asked Aug 02 '11 15:08

Benjamin K.


2 Answers

Use QPlainTextEdit for large log files -- that's what it was designed for. You don't get the full range of options that QTextEdit provides, but you can set the font and the text colour.

like image 104
TonyK Avatar answered Oct 28 '22 22:10

TonyK


Since your log is presumably tabular at some level, then the Model/View framework sounds like it could work for you. Perhaps you could try using a QListView with QGraphicsTextItem:

http://doc.qt.nokia.com/latest/qgraphicstextitem.html

It has methods for setting/getting the HTML:

http://doc.qt.nokia.com/latest/qgraphicstextitem.html#setHtml

http://doc.qt.nokia.com/latest/qgraphicstextitem.html#toHtml

You'll get some benefits and hassles from writing it that way. But you should certainly be able to finesse the insertions and append speed.

like image 1
HostileFork says dont trust SE Avatar answered Oct 28 '22 20:10

HostileFork says dont trust SE