summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-10-10 15:33:04 +0200
committerZhang Hao <zhanghao@uniontech.com>2021-10-13 14:27:12 +0000
commitf7a4a79c62daeba9ab5545c5e0a1f36d5e1fce6b (patch)
tree3a3dcbee82211be6f4e83fca03af7259f03e8286 /src
parenta34a10c11f11c99f35696874b5a82d6e843ebec2 (diff)
Take overshoot into account when laying out QAbstractScrollArea
QAbstractScrollAreaPrivate::layoutChildren() positions the viewport, but did not take the overshoot from scrolling with a scroller into account. If the scroll area was resized during a scroll, then this resulted in the roll back overcompensating for the overshoot, placing the viewport outside the visible area. Fix this by taking the overshoot into account when positioning the viewport. Add a test case. We have to use QWindow-based mouse event simulation, as the QWidget based move events use QCursor::setPos, which doesn't reliably go through the gesture framework. Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Done-with: Zhang Hao <zhanghao@uniontech.com> Fixes: QTBUG-94769 Pick-to: 5.15 6.2 Change-Id: Idf650c91e5a9cffa996e23e743939243b1d4fcc0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 23496a2e51..4ad8a3b411 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -442,8 +442,10 @@ void QAbstractScrollAreaPrivate::layoutChildren_helper(bool *needHorizontalScrol
viewportRect.adjust(right, top, -left, -bottom);
else
viewportRect.adjust(left, top, -right, -bottom);
+ viewportRect = QStyle::visualRect(opt.direction, opt.rect, viewportRect);
+ viewportRect.translate(-overshoot);
+ viewport->setGeometry(viewportRect); // resize the viewport last
- viewport->setGeometry(QStyle::visualRect(opt.direction, opt.rect, viewportRect)); // resize the viewport last
*needHorizontalScrollbar = needh;
*needVerticalScrollbar = needv;
}