From da7d894deb4cc36155ade5e6a1ebecc3262363f8 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 16 Jan 2018 15:22:40 +0100 Subject: Make Tumbler compatible with deferred execution Now that the contentItem is created at a different stage, we have to shuffle some code around and add some null checks. Task-number: QTBUG-50992 Change-Id: I34d3a9ea9cb9ab54008a1015b37b1666538c085e Reviewed-by: J-P Nurmi --- src/quickcontrols2/qquicktumblerview.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/quickcontrols2') diff --git a/src/quickcontrols2/qquicktumblerview.cpp b/src/quickcontrols2/qquicktumblerview.cpp index e8f0c364..4469810c 100644 --- a/src/quickcontrols2/qquicktumblerview.cpp +++ b/src/quickcontrols2/qquicktumblerview.cpp @@ -173,14 +173,19 @@ void QQuickTumblerView::createView() m_listView->setParentItem(this); m_listView->setSnapMode(QQuickListView::SnapToItem); m_listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange); - m_listView->setHighlightMoveDuration(1000); m_listView->setClip(true); - m_listView->setDelegate(m_delegate); // Give the view a size. updateView(); // Set the model. updateModel(); + + // Set these after the model is set so that the currentItem animation + // happens instantly on startup/after switching models. If we set them too early, + // the view animates any potential currentIndex change over one second, + // which we don't want when the contentItem has just been created. + m_listView->setDelegate(m_delegate); + m_listView->setHighlightMoveDuration(1000); } } } -- cgit v1.2.3