I have text edit class that inherits QAbstractScrollArea
, in Qt, Which I use to display some lines. When the number of lines become 1000
, the oldest line is moved out, and new line takes its place.
But I store all the lines that are moved out, so that if the user scrolls up, I can display it to him when the scroll reaches its minimum boundary. I do this by following signal and slot
.
connect(myArea->verticalScrollBar(),SIGNAL(valueChanged(int)),myArea,SLOT(myslot()));
and the slot is:
void myslot()
{
if(this->verticalScrollBar()->value() == this->verticalScrollBar()->minimum())
{
//LOAD STORED LINE
}
}
Problem
The problem is I want to scroll bar to behave as if there are more lines above. I want the scroll bar to reflect that there are lines above,(actually there are none), meaning is there a way in which I can tweak the scroll bar to not hit the minimum boundary as long as there lines stored to be displayed from the data structure?
What I tried
If( scroll bar hits upper boundary and data structure has lines in store)
{
this->verticalScrollBar()->setValue( value greater than minimum);
}
But its not a smooth transition, like a normal scroll. Any ideas would be appreciated.