How exactly do you input text to QTextEdit? How did you setup QTextEdit? Can't you use QPlainTextEdit instead?
How exactly do you input text to QTextEdit? How did you setup QTextEdit? Can't you use QPlainTextEdit instead?
In addition to what wysota wrote, it would probably be better if you first read in to a QString or QStringList, and only after the file reading is done, to do one setText() in to the QTextEdit.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
wysota: I am using append to insert line by line. Before I check every line with a QRegExp for containing links
high_flyer: Using setText seems not to be a option, since the QTextEdit works like a console (line after line and not 500 lines once)
Using PlainTextEdit gives a far more better performance. Thats what I need. Sadly PlainTextEdit does not support links (which I need), but maybe its better to do a tradeoff here:
Under normal circumstances the performace of QTextEdit is ok. Only if a lot of output is produced I ran into problems. Maybe I should switch from QTextEdit to a PlainTextEdit if my internal buffer reaches a specific size (that should be an indicator, that the inserting is to slow) I should switch to a PlainTextEdit. Than I lost the links, but the program remains stable and fast.
Nevertheless I have another idea: I already limited the maximum lines to 1000. I also observed, that sometimes my internal buffer reaches 50.000 remaining lines. In the PlainTextEdit the are inserted really fast (to fast to follow) and maybe its a good idea to skip just 49.000 lines and show only the last 1000 lines, since the other lines are useless for the user.
Last edited by nightghost; 22nd January 2010 at 12:52.
Bad idea, this method is terribly slow. Use QTextCursor interface instead.
Ouch, that slows it down even more. What do you need the links for?Before I check every line with a QRegExp for containing links
It's not a big of a problem. You can visually mark the links using a syntax highlighter (which will make your QRegExp go away or at least move to a different place) and then you can handle the links by implementing mouse event handlers for your editor.Using PlainTextEdit gives a far more better performance. Thats what I need. Sadly PlainTextEdit does not support links (which I need), but maybe its better to do a tradeoff here:
I would certainly not agree with that statement.Under normal circumstances the performace of QTextEdit is ok.
1.) A ok. I did'nt know, that this would make a difference
2.) The output is mostly from the GCC. The QRegExp is used to detect absolute paths and make links of them to click and jump (warnings, errors messages)
3.) Nice idea, but is this really faster? Matching the links in the SyntaxHighLighter or before adding sounds not like a big difference. But it sounds like a good idea to enable the link-feature and leave the log output untouched
4.) Hmm, ok :-) Its fast enough to be not annoying ;-)
nightghost (25th January 2010)
Ah ok. The SyntaxHighligher is a lot faster in formating the text then the rich-text engine. Thanks for the tip
The rich text engine has to parse the text each time it is being laid out (or at least each time the text changes). The syntax highlighter uses QTextDocument infrastructure.
Thanks for the explanation. I'll have to investigate that further
Bookmarks