aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorNicolas Fella <nicolas.fella@kdab.com>2020-05-09 14:18:52 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-05-20 09:00:52 +0200
commitcd6fc97f273afe3ddc2780d77ea5094e8e41ab8f (patch)
treeddba9af0ada02d2193bf55613edef074ee5b2326 /src/quick/items
parentb782a8571c1d4465c6ee5821ba65e2017361a2ec (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. 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> (cherry picked from commit a071befa4f96e2df51d9a98b0f3d2700d791e7a5)
Diffstat (limited to 'src/quick/items')
-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 c91a5ef92b..8228db87cf 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -1809,7 +1809,7 @@ void QQuickFlickable::geometryChanged(const QRectF &newGeometry,
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;
@@ -1819,7 +1819,7 @@ void QQuickFlickable::geometryChanged(const QRectF &newGeometry,
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;
@@ -2080,7 +2080,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();
@@ -2109,7 +2109,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();