QTextEdit slow to insert text
I've got an application that uses a QTextEdit that gets text inserted in it, often only 4-20 characters at a time quite frequently. Normally, I'm setting a different color, inserting about 20 characters, changing colors, inserting more text, etc. Problem is that the text inserts pretty slowly. I'd say it takes about 100 lines of differently colored text about 1sec to be drawn in. Thats running on my laptop ~PentiumM 1.7Ghz. It just seems really, really slow. As far as I can tell, it seems to be a problem with the QTextEdit just being slow. I read somewhere that theres some horrible performance issues with the scrollbars. I'm trying to append text to the QTextEdit and keep the QTextEdit scrolled down to the bottom of the text, So I'm often calling
Code:
QTextEdit->verticalScrollbar->setValue( mp_scrollBar->maximum() );
I'm inserting all plaintext, no HTML by the QTextEdit's insertPlainText method... Am I doing this the wrong way? Should I be inserting text into the QTextDocument that the QTextEdit uses instead? Or is the QTextEdit just slow for inserting new text?
Thanks,
Paul
Re: QTextEdit slow to insert text
Your method is fine. Are you sure the slowdown is caused by inserting text and nothing else?
Re: QTextEdit slow to insert text
That was stupid of me. I was calling qApp->processEvents() everytime text was inserted. I was doing that back when I was stepping through my code and wanted to see the updated text immediately. Removed the call and now it flys ;p
Paul
Re: QTextEdit slow to insert text
One related question. Is there a way to tell Qt to process GUI events for a specific widget? SO instead of saying qApp->processEvents() I could just do myWidget->processEvents() ??
Paul
Re: QTextEdit slow to insert text