diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2019-02-14 14:49:05 +0100 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2019-02-18 13:31:49 +0000 |
commit | f14fa8b42c2d09afbc27209ffc520dfaf6dbc4d7 (patch) | |
tree | 42ab4e1738e5cd22c229ba3795d6ad630f64a13b | |
parent | 0614d792967b7721c692cb273bb5428544fa3680 (diff) |
QQuickScrollView: only forward content size to flickable if set explicit
TableView monitors if the application sets an explicit
contentWidth/Height, and skips calculating it when that is the case.
So be more careful from ScrollView, and don't set it on the
flickable if the application did not set it explicitly.
By doing it this way, you can now set an explicit contentWidth/Height
both in ScrollView and TableView, and it will be respected.
Task-number: QTBUG-72536
Change-Id: Ib87fa6958881fccdc47f50133e996484392281b6
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/quicktemplates2/qquickscrollview.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquickscrollview.cpp b/src/quicktemplates2/qquickscrollview.cpp index 57b0177e..7890a30a 100644 --- a/src/quicktemplates2/qquickscrollview.cpp +++ b/src/quicktemplates2/qquickscrollview.cpp @@ -154,6 +154,7 @@ public: bool wasTouched = false; QQuickFlickable *flickable = nullptr; + bool ownsFlickable = false; }; QList<QQuickItem *> QQuickScrollViewPrivate::contentChildItems() const @@ -174,8 +175,10 @@ QQuickItem *QQuickScrollViewPrivate::getContentItem() QQuickFlickable *QQuickScrollViewPrivate::ensureFlickable(bool content) { Q_Q(QQuickScrollView); - if (!flickable) + if (!flickable) { setFlickable(new QQuickFlickable(q), content); + ownsFlickable = true; + } return flickable; } @@ -563,8 +566,16 @@ void QQuickScrollView::contentSizeChange(const QSizeF &newSize, const QSizeF &ol Q_D(QQuickScrollView); QQuickPane::contentSizeChange(newSize, oldSize); if (d->flickable) { - d->flickable->setContentWidth(newSize.width()); - d->flickable->setContentHeight(newSize.height()); + // Only set the content size on the flickable if we created the + // flickable ourselves. Otherwise we can end up overwriting + // assignments done to those properties by the application. The + // exception is if the application has assigned a content size + // directly to the scrollview, which will then win even if the + // application has assigned something else to the flickable. + if (d->hasContentWidth || d->ownsFlickable) + d->flickable->setContentWidth(newSize.width()); + if (d->hasContentHeight || d->ownsFlickable) + d->flickable->setContentHeight(newSize.height()); } } |