QPlainTextEdit stops updating
-
Hi, I'm having issues with QPlainText edit. I'm using it to display an output log. There's a lot of text and updates (1 line/1ms). After a lot of text is displayed and more is displaying, the app crashes.
To fix the crashing, I decided to limit how many characters can be in there at once, 4 thousand. So, I took the text from QPlainTextEdit, removed the characters and set the text. That doesn't work. When the modification gets triggered, QPlainTextEdit freezes and doesn't update, untill you click in it. Also the text updates depending where you clicked, so half of it can just be stuck, while the other half is updating.Here's the modification code:
QString text = ui->plainTextEdit_Log->toPlainText(); int check = text.count(); if (check > 10000) { qDebug() << "triggered"; text.remove(0, 6000); ui->plainTextEdit_Log->setPlainText(text); ui->plainTextEdit_Log->verticalScrollBar()->setValue(ui->plainTextEdit_Log->verticalScrollBar()->maximum()); qDebug() << "finished"; }Can I fix this somehow?
-
Hi, I'm having issues with QPlainText edit. I'm using it to display an output log. There's a lot of text and updates (1 line/1ms). After a lot of text is displayed and more is displaying, the app crashes.
To fix the crashing, I decided to limit how many characters can be in there at once, 4 thousand. So, I took the text from QPlainTextEdit, removed the characters and set the text. That doesn't work. When the modification gets triggered, QPlainTextEdit freezes and doesn't update, untill you click in it. Also the text updates depending where you clicked, so half of it can just be stuck, while the other half is updating.Here's the modification code:
QString text = ui->plainTextEdit_Log->toPlainText(); int check = text.count(); if (check > 10000) { qDebug() << "triggered"; text.remove(0, 6000); ui->plainTextEdit_Log->setPlainText(text); ui->plainTextEdit_Log->verticalScrollBar()->setValue(ui->plainTextEdit_Log->verticalScrollBar()->maximum()); qDebug() << "finished"; }Can I fix this somehow?
@Sucharek said in QPlainTextEdit stops updating:
There's a lot of text and updates (1 line/1ms)
I have not/cannot test this. It seems pretty unreasonably frequent if this is your issue. User cannot see updates so fast. If you cannot resolve, what about buffering these updates to no more than ten times a second or whatever, does that improve? And/or maybe use the
QTextCursorto append at the end, setting the complete text edit 4k at a time might be "slow"? -
Hi, I'm having issues with QPlainText edit. I'm using it to display an output log. There's a lot of text and updates (1 line/1ms). After a lot of text is displayed and more is displaying, the app crashes.
To fix the crashing, I decided to limit how many characters can be in there at once, 4 thousand. So, I took the text from QPlainTextEdit, removed the characters and set the text. That doesn't work. When the modification gets triggered, QPlainTextEdit freezes and doesn't update, untill you click in it. Also the text updates depending where you clicked, so half of it can just be stuck, while the other half is updating.Here's the modification code:
QString text = ui->plainTextEdit_Log->toPlainText(); int check = text.count(); if (check > 10000) { qDebug() << "triggered"; text.remove(0, 6000); ui->plainTextEdit_Log->setPlainText(text); ui->plainTextEdit_Log->verticalScrollBar()->setValue(ui->plainTextEdit_Log->verticalScrollBar()->maximum()); qDebug() << "finished"; }Can I fix this somehow?
-
@Sucharek said in QPlainTextEdit stops updating:
ui->plainTextEdit_Log->verticalScrollBar()->setValue(ui->plainTextEdit_Log->verticalScrollBar()->maximum());
Does it work if you comment this line out?
-
Hi, I'm having issues with QPlainText edit. I'm using it to display an output log. There's a lot of text and updates (1 line/1ms). After a lot of text is displayed and more is displaying, the app crashes.
To fix the crashing, I decided to limit how many characters can be in there at once, 4 thousand. So, I took the text from QPlainTextEdit, removed the characters and set the text. That doesn't work. When the modification gets triggered, QPlainTextEdit freezes and doesn't update, untill you click in it. Also the text updates depending where you clicked, so half of it can just be stuck, while the other half is updating.Here's the modification code:
QString text = ui->plainTextEdit_Log->toPlainText(); int check = text.count(); if (check > 10000) { qDebug() << "triggered"; text.remove(0, 6000); ui->plainTextEdit_Log->setPlainText(text); ui->plainTextEdit_Log->verticalScrollBar()->setValue(ui->plainTextEdit_Log->verticalScrollBar()->maximum()); qDebug() << "finished"; }Can I fix this somehow?
@Sucharek said in QPlainTextEdit stops updating:
There's a lot of text and updates (1 line/1ms)
I have not/cannot test this. It seems pretty unreasonably frequent if this is your issue. User cannot see updates so fast. If you cannot resolve, what about buffering these updates to no more than ten times a second or whatever, does that improve? And/or maybe use the
QTextCursorto append at the end, setting the complete text edit 4k at a time might be "slow"? -
@Sucharek said in QPlainTextEdit stops updating:
There's a lot of text and updates (1 line/1ms)
I have not/cannot test this. It seems pretty unreasonably frequent if this is your issue. User cannot see updates so fast. If you cannot resolve, what about buffering these updates to no more than ten times a second or whatever, does that improve? And/or maybe use the
QTextCursorto append at the end, setting the complete text edit 4k at a time might be "slow"?