From 908aa77d16e00f2bccc0ddae0f8b61955c56a6a1 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 10 May 2021 12:56:39 +0200 Subject: Hide old scroll bars Reuse the hideOldItem added in 80f1186338bcf8c7d692b4fadfc46531c002c6b0 to unparent and hide them. Fixes: QTBUG-89126 Pick-to: 6.1 5.15 Change-Id: I641e46571b8ac42e0e5080b6737f305ff59afd51 Reviewed-by: Fabian Kosmale --- src/quicktemplates2/qquickscrollbar.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp index a03552f7..dfa8d1bd 100644 --- a/src/quicktemplates2/qquickscrollbar.cpp +++ b/src/quicktemplates2/qquickscrollbar.cpp @@ -972,6 +972,16 @@ void QQuickScrollBarAttachedPrivate::cleanupHorizontal() { Q_ASSERT(flickable && horizontal); + QQuickControlPrivate::hideOldItem(horizontal); + // ScrollBar.qml has a binding to visible and ScrollView.qml has a binding to parent. + // If we just set visible to false and parent to null, these bindings will overwrite + // them upon component completion as part of the binding evaluation. + // That's why we remove the binding completely. + const QQmlProperty visibleProperty(horizontal, QStringLiteral("visible")); + const QQmlProperty parentProperty(horizontal, QStringLiteral("parent")); + QQmlPropertyPrivate::removeBinding(visibleProperty); + QQmlPropertyPrivate::removeBinding(parentProperty); + disconnect(flickable, &QQuickFlickable::movingHorizontallyChanged, this, &QQuickScrollBarAttachedPrivate::activateHorizontal); // TODO: export QQuickFlickableVisibleArea @@ -984,6 +994,12 @@ void QQuickScrollBarAttachedPrivate::cleanupVertical() { Q_ASSERT(flickable && vertical); + QQuickControlPrivate::hideOldItem(vertical); + const QQmlProperty visibleProperty(vertical, QStringLiteral("visible")); + const QQmlProperty parentProperty(vertical, QStringLiteral("parent")); + QQmlPropertyPrivate::removeBinding(visibleProperty); + QQmlPropertyPrivate::removeBinding(parentProperty); + disconnect(flickable, &QQuickFlickable::movingVerticallyChanged, this, &QQuickScrollBarAttachedPrivate::activateVertical); // TODO: export QQuickFlickableVisibleArea -- cgit v1.2.3