I have a QPlainTextEdit
, in which I append new lines dynamically. If at any given time the number of lines currently in QPlainTextEdit
becomes 500, I remove the oldest line and keep the number of lines constant.
We can easily achieve this by using following:
ui->plainTextEdit->setMaximumBlockCount(500);
OK. But I dont want the user to know that I remove lines when maximum block count is reached. This means I have to decrease the size of the scrollbar, just like it would decreased automatically, when we do not, set the setMaximumBlockCount
, property.
But because we have set the setMaximumBlockCount
, property, the size of scrollbar will remain constant after the maximum block count is reached.
If I am able to decrease the size of scroll bar, then we will successfully give the illusion that we are not removing any lines.
My Second question is:
If we successfully give this illusion effect to the user and say we load 10000 lines.
So our QPlainTextEdit
, will currently store the last 500 lines of 10000 lines. But because of the illusion effect ,the user will assume he can view all the 10000 lines.
So when the user scrolls up, I have to maintain the illusion effect. This means if the user scrolls up, I need to display the old lines that were removed.
Since the QPlainTextEdit
, does not have a prepend
, operation, I do this by saving the lines in file, and reading the lines from file when necessary and repopulate the entire QPlainTextEdit
. But main thing is we have to keep the scroll bar as it is even when we completely repopulate the QPlainTextEdit
, to maintain the illusion effect.
Any ideas or links or answers would be appreciated.