[UNSOLVED]QPlainTextEdit / QTextEdit performance issues using set or append methods
Gd day,
I have read recently a topic named "QPlainTextEdit performance in Qt 4.7.0", as topic itself referred only to Qt 4.7.0 I started this one.
We can see that author wrote
Quote:
Originally Posted by
Carlsberg
...I've narrowed down by comenting stuff in my update method and it all comes to this
Code:
m_viewport->setPlainText(dataBuffer);
After that we can read that author himself "solved" the problem.
Quote:
Originally Posted by
Carlsberg
Happens the same on 4.7.2. So, compiled with 4.5.1 it's lighting fast, compiled with 4.7.0 and 4.7.2 it's amazingly slow
My case:
Code:
this->appendPlainText(finalLogContents);
Used as recommended in documentation with
Code:
setMaximumBlockCount = 80;
works the same as
Code:
this->setPlainText(finalLogContents);
Text in my QPlainTextEdit is refreshed every scroll made using either - every time call to consumes about 40% of 2.6 GHz CPU - it is way too much. Everytime variable named consist of 80-100 lines depending on screen resolution.
I am thinking that maybe textChanged() SIGNAL is causing trouble - I will check it in a while with blockSignals().
Question:
Is there a method which use instead of QString(I think it will be way faster cause I store all my data in Should I revert to 4.5.1 or reimplement all crucial methods and create own fully customized TextEdit or maybe find another way using native QPlainTextEdit?
Thank you in advance, please post any even strange idea! :)
Edit 1:
Unfortunately textChanged SIGNAL is not causing my problem since it is not connected to any slot thus blocking it with QObject::blockSignals() gives nothing.
Re: QPlainTextEdit / QTextEdit performance issues using set or append methods
We can see that author wrote...
No, you can see. Nobody else can. Why didn't you link it?
Have you tried text modification using QTextCursor?
Re: QPlainTextEdit / QTextEdit performance issues using set or append methods
Quote:
Originally Posted by
amleto
We can see that author wrote...
No, you can see. Nobody else can. Why didn't you link it?
Have you tried text modification using QTextCursor?
You are more than right, but topic is very short - this explains my attitude ;)
http://www.qtcentre.org/threads/3926...ce-in-Qt-4-7-0
Regarding QTextCursor - I didn't try it - will do it in a couple of minutes.
Re: QPlainTextEdit / QTextEdit performance issues using set or append methods
additionally, have you made sure you are running a release build? (with the various iterator check disabling macros defined if you are using msvc and stl - yes, some are still enabled in release in studio 2005 and 2008 iirc)
Re: QPlainTextEdit / QTextEdit performance issues using set or append methods
Quote:
Originally Posted by
amleto
additionally, have you made sure you are running a release build? (with the various iterator check disabling macros defined if you are using msvc and stl - yes, some are still enabled in release in studio 2005 and 2008 iirc)
Yes tried release build both on MinGW and MSVC 2008 using Qt 4.8.0
Edit 1:
Tried using QTextCursor insertText() method without any luck still big CPU usage which causes sluggish GUI.
Pasting function which is responsible for setting text. CustomTextEdit inherits from QPlainTextEdit.
Code:
void CustomLogView
::updateLogViewTextCursor(const QString &finalLogContents,
const bool firstUpdate
) {
qDebug() << "CALL -> " + CommonFunctions::getCurrentTime();
//QString finalLogContents = "A";
if(firstUpdate)
{
this->document()->setPlainText(finalLogContents);
//this->appendPlainText(finalLogContents);
}
else
{
this->document()->setPlainText(finalLogContents);
int line = getLine(cursor);
int column = getIndex(cursor);
int i = 0;
for( ; block != this->document()->end(); block = block.next(), ++i )
{
if(i == line)
{
cursor.setPosition(block.position() + column);
break;
}
}
this->setTextCursor(cursor);
}
}
Edit 2:
QTextCursor with insertText() mixed with beginBlockEdit() and endBlockEdit() gives me less sluggish GUI. Looks better, will try more fixes.
Edit 3:
Finally found some library code:
Code:
{
bool previousState = d->isUndoRedoEnabled();
d->enableUndoRedo(false);
d->beginEditBlock();
d->clear();
d->endEditBlock();
d->enableUndoRedo(previousState);
}
Using setPlainText() makes app slower (besides calling many functions in the chain) especially if you set enableUndoRedo(false).
Will research and revert with more info.
Re: QPlainTextEdit / QTextEdit performance issues using set or append methods
Bumping thread a little.
Wondering if function in will speed it up, anyone had experience with this?
Re: [UNSOLVED]QPlainTextEdit / QTextEdit performance issues using set or append metho
Hi nearly the same Problem here have you found any solution so far ?
I have a 6MB big .txt file to read wich takes several minutes to show up in PlainTextEdit.
I think it is some kind of memory Problem which causes CPU usage to explode.
thx in advance