aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickflickable.cpp
diff options
context:
space:
mode:
authorNicolas Fella <nicolas.fella@kdab.com>2020-05-09 14:18:52 +0200
committerNicolas Fella <nicolas.fella@kdab.com>2020-05-15 13:19:48 +0200
commita071befa4f96e2df51d9a98b0f3d2700d791e7a5 (patch)
tree0d2f34393068d246321c4c8489d30f38791a45a1 /src/quick/items/qquickflickable.cpp
parent08f24666e122f220ad4b1d65b2feaa5f58648f1a (diff)
Respect margins when sizing flickable content item
When setting the width/height of the content item we need to take the margins into account. Otherwise for example a left margin of 10 causes the content item to exceed the parent by 10 pixels to the right. This causes, amongst possibly other issues, misaligned headers/footers. Pick-to: 5.15 Change-Id: Ib620bb3be4a4f620b61f14564beb92ceb10ab02f Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Marco Martin <mart@kde.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickflickable.cpp')
-rw-r--r--src/quick/items/qquickflickable.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index 00cd0a2d61..fed4bbec5e 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -1808,7 +1808,7 @@ void QQuickFlickable::geometryChange(const QRectF &newGeometry, const QRectF &ol
if (newGeometry.width() != oldGeometry.width()) {
changed = true; // we must update visualArea.widthRatio
if (d->hData.viewSize < 0)
- d->contentItem->setWidth(width());
+ d->contentItem->setWidth(width() - d->hData.startMargin - d->hData.endMargin);
// Make sure that we're entirely in view.
if (!d->pressed && !d->hData.moving && !d->vData.moving) {
d->fixupMode = QQuickFlickablePrivate::Immediate;
@@ -1818,7 +1818,7 @@ void QQuickFlickable::geometryChange(const QRectF &newGeometry, const QRectF &ol
if (newGeometry.height() != oldGeometry.height()) {
changed = true; // we must update visualArea.heightRatio
if (d->vData.viewSize < 0)
- d->contentItem->setHeight(height());
+ d->contentItem->setHeight(height() - d->vData.startMargin - d->vData.endMargin);
// Make sure that we're entirely in view.
if (!d->pressed && !d->hData.moving && !d->vData.moving) {
d->fixupMode = QQuickFlickablePrivate::Immediate;
@@ -2079,7 +2079,7 @@ void QQuickFlickable::setContentWidth(qreal w)
return;
d->hData.viewSize = w;
if (w < 0)
- d->contentItem->setWidth(width());
+ d->contentItem->setWidth(width() - d->hData.startMargin - d->hData.endMargin);
else
d->contentItem->setWidth(w);
d->hData.markExtentsDirty();
@@ -2108,7 +2108,7 @@ void QQuickFlickable::setContentHeight(qreal h)
return;
d->vData.viewSize = h;
if (h < 0)
- d->contentItem->setHeight(height());
+ d->contentItem->setHeight(height() - d->vData.startMargin - d->vData.endMargin);
else
d->contentItem->setHeight(h);
d->vData.markExtentsDirty();