Qt is the best way to display very large rich text?

I need to display very large logs that use HTML tags to label different types of data.

Using QTextEdit and QTextBrowser really slows down the application, especially when adding operations. I really would like to support the QTextEdit interface and features.

I saw people who implemented their own TextEdit style to improve performance, but I wandered if someone solved this problem with Qt tools. I was thinking about using the Model / View infrastructure to load data on demand, but this is not quite what I was thinking.

Maybe subclassing QTextEdit and overriding some of its scroll slots ...

If anyone ran into this problem and solved it, I would appreciate some advice.

Thanks.

+7
source share
4 answers

Since your journal is supposedly tabular at some level, then the Model / View structure looks as if it could work for you. Perhaps you can try using QListView with QGraphicsTextItem :

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

It has methods for installing / receiving HTML:

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

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

You will get some benefits and trouble from writing this. But you can certainly improve the inserts and add speed.

+1
source

Use QPlainTextEdit for large log files - what it is for. You do not get the full set of options provided by QTextEdit , but you can set the font and color of the text.

+2
source

why not use QWebKit ? The module itself is quite heavy, but the rendering speed is very good.

0
source

Since the ROI when reimplementing QTextEdit with the Model / View architecture is low, I will go with @spraff's comment on the use of paging.

Basically, I will limit the number of lines that are stored in my log, since the log is also dumped to the file, if the user needs something from the past or the future (by adding special buttons), I will read it from the file dynamically (lightweight model / view .. ..).

0
source

All Articles