QTextBrowser::setPlainText and setSource calls take extremely long for large texts
-
QTextBrowser::setPlainText
takes very long (about 1 minute for debug build) with a 14 MB ASCII text. Consumes 170-180 MB of memory, too (what for?!!). Once the text is loaded, the widget's performance is great - smooth scrolling etc., no problem. But such a long loading time makes it unusable. Is there anything I can do to speed it up? -
The debug mode is always much slower then the release build. If you encounter this type of behavior, always check if the release mode is acceptable in terms of delays. Maybe the use of QTextEdit might speed things up?
-
No, it's faster in release but not by much. Still pretty much unusable.
I think I used theQTextBrowser
to enable HTML viewing, and I don't need an editor, just a viewer. Gonna tryQTextEdit
anyway, will be interesting to see if it's any faster. -
Why do you want to use the setPlainText function? Is the file not readable just as it is? The QTextBrowser supports setSource(). Maybe that will speed up the load?
-
As I mentioned in the title, I've also tried
setSource
and there's no difference. Reading the file and loading it intoQString
is not the problem. Filling theQTextBrowser
is. -
Turns out,
QPlainTextEdit
is fast whileQTextEdit
is slow. It has another problem, though: It takes ENORMOUS amount of time to free its internal memory blocks (QTextBlockData objects) when I clear the viewer.