QTextBrowser::setPlainText and setSource calls take extremely long for large texts
-
QTextBrowser::setPlainTexttakes 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 theQTextBrowserto enable HTML viewing, and I don't need an editor, just a viewer. Gonna tryQTextEditanyway, 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
setSourceand there's no difference. Reading the file and loading it intoQStringis not the problem. Filling theQTextBrowseris. -
Turns out,
QPlainTextEditis fast whileQTextEditis 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.