Problem with QPlainTextEdit
-
I need to show data like a terminal in QT (Like Arduino with a Serial port). I'm using a QPlainTextEdit because it is the only option I've found. But it adds so much latency and makes the app laggy.
Here is with QTextEdit.
Here without it.
Is there anyway to make it not laggy or to show data like arduino's serial monitor? -
I need to show data like a terminal in QT (Like Arduino with a Serial port). I'm using a QPlainTextEdit because it is the only option I've found. But it adds so much latency and makes the app laggy.
Here is with QTextEdit.
Here without it.
Is there anyway to make it not laggy or to show data like arduino's serial monitor? -
This is the code of the QTextEdit
cursor.movePosition(QTextCursor::Start); cursor.insertText(show); nLines += 2; if (nLines < -100) { nLines -= 2; cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, nLines-1); cursor.select(QTextCursor::LineUnderCursor); cursor.removeSelectedText(); cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, 1); cursor.select(QTextCursor::LineUnderCursor); cursor.removeSelectedText(); cursor.deleteChar(); }
-
This is the code of the QTextEdit
cursor.movePosition(QTextCursor::Start); cursor.insertText(show); nLines += 2; if (nLines < -100) { nLines -= 2; cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, nLines-1); cursor.select(QTextCursor::LineUnderCursor); cursor.removeSelectedText(); cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, 1); cursor.select(QTextCursor::LineUnderCursor); cursor.removeSelectedText(); cursor.deleteChar(); }
@GGG03
That is quite a bit of moving the cursor around, selecting, scrolling etc. It might be the case that reading the whole text from the text edit (or keeping it in memory), deleting the first line in memory from it, appending the new stuff and doing a completesetText()
could be faster, you'd have to try. Or, I can't figure how often you are updating, you might want to "buffer" a few updates at a time. For example, user cannot read text updated e.g. every 1ms so no need to. -
@GGG03
That is quite a bit of moving the cursor around, selecting, scrolling etc. It might be the case that reading the whole text from the text edit (or keeping it in memory), deleting the first line in memory from it, appending the new stuff and doing a completesetText()
could be faster, you'd have to try. Or, I can't figure how often you are updating, you might want to "buffer" a few updates at a time. For example, user cannot read text updated e.g. every 1ms so no need to. -
@GGG03
That is quite a bit of moving the cursor around, selecting, scrolling etc. It might be the case that reading the whole text from the text edit (or keeping it in memory), deleting the first line in memory from it, appending the new stuff and doing a completesetText()
could be faster, you'd have to try. Or, I can't figure how often you are updating, you might want to "buffer" a few updates at a time. For example, user cannot read text updated e.g. every 1ms so no need to. -
I found the problem. It was the font. I was using Terminal 9, and with Segou UI it is not laggy.
-
-
I found the problem. It was the font. I was using Terminal 9, and with Segou UI it is not laggy.