PDA

View Full Version : QScrollArea stay down



bunjee
3rd June 2008, 01:25
Is there a way to force QScrollArea to stay down ?

Like an instant messenger conversation.

I tried with the following implementation, but it makes the view flickers:


void ZeScrollAreaWidget::onRangeChanged(int min, int max)
{
if (isStayDown() == true)
{
if (verticalScrollBar()->sliderPosition() == mOldMax
||
mOldMax == -1)
{
verticalScrollBar()->setSliderPosition(max);
}
}

mOldMax = max;
}

Is there a way to avoid this hack? Or do I have to reimplement QAbstractScrollArea

Thanks.

aamer4yu
3rd June 2008, 05:48
You want that the slider autmatically scrolls down as the chat is in progress ??
Have a look at
QScrollArea::ensureWidgetVisible and

QScrollArea::ensureVisible

Hope it helps :)

bunjee
3rd June 2008, 11:14
Thanks,

It works, but when calling it in a resizeEvent : flickering persist.

I think I have to come up with my onw QScrollArea ;).