-void ChatView::sceneHeightChanged(qreal h) {
- Q_UNUSED(h)
- bool scrollable = qAbs(verticalScrollBar()->value() - verticalScrollBar()->maximum()) <= 2; // be a bit tolerant here, also FIXME (why we need this?)
- setSceneRect(scene()->sceneRect());
- if(scrollable) verticalScrollBar()->setValue(verticalScrollBar()->maximum());
+void ChatView::sceneHeightChanged(qreal dh) {
+ QAbstractSlider *vbar = verticalScrollBar();
+ Q_ASSERT(vbar);
+ if(vbar->maximum() - vbar->value() <= dh + 5) // in case we had scrolled only about half a line to the bottom we allow a grace of 5
+ vbar->setValue(vbar->maximum());