diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-01-18 16:29:14 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-01-27 10:40:01 +0000 |
commit | a9aa500a680058d7f2a75f02ad8d72c4b1e49f7c (patch) | |
tree | ff3ed2134ec7d966736a875f0b08ee74e0524b40 /src/quicktemplates2/qquickscrollbar.cpp | |
parent | 0942e5cd6f1e4c8eac45a77c5deece671a6f513b (diff) |
Add ScrollView
[ChangeLog][Controls][ScrollView] Added ScrollView.
Change-Id: I5d68799f0246e04b519bf6a0ec7bc7e5625f50e7
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/quicktemplates2/qquickscrollbar.cpp')
-rw-r--r-- | src/quicktemplates2/qquickscrollbar.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp index bb29ebd6..1ad14e9d 100644 --- a/src/quicktemplates2/qquickscrollbar.cpp +++ b/src/quicktemplates2/qquickscrollbar.cpp @@ -36,6 +36,7 @@ #include "qquickscrollbar_p.h" #include "qquickscrollbar_p_p.h" +#include "qquickscrollview_p.h" #include <QtQml/qqmlinfo.h> #include <QtQuick/private/qquickflickable_p.h> @@ -662,6 +663,11 @@ void QQuickScrollBarAttachedPrivate::initHorizontal() QObject::connect(area, SIGNAL(widthRatioChanged(qreal)), horizontal, SLOT(setSize(qreal))); QObject::connect(area, SIGNAL(xPositionChanged(qreal)), horizontal, SLOT(setPosition(qreal))); + // ensure that the ScrollBar is stacked above the Flickable in a ScrollView + QQuickItem *parent = horizontal->parentItem(); + if (parent && parent == flickable->parentItem()) + horizontal->stackAfter(flickable); + layoutHorizontal(); horizontal->setSize(area->property("widthRatio").toReal()); horizontal->setPosition(area->property("xPosition").toReal()); @@ -678,6 +684,11 @@ void QQuickScrollBarAttachedPrivate::initVertical() QObject::connect(area, SIGNAL(heightRatioChanged(qreal)), vertical, SLOT(setSize(qreal))); QObject::connect(area, SIGNAL(yPositionChanged(qreal)), vertical, SLOT(setPosition(qreal))); + // ensure that the ScrollBar is stacked above the Flickable in a ScrollView + QQuickItem *parent = vertical->parentItem(); + if (parent && parent == flickable->parentItem()) + vertical->stackAfter(flickable); + layoutVertical(); vertical->setSize(area->property("heightRatio").toReal()); vertical->setPosition(area->property("yPosition").toReal()); @@ -824,8 +835,8 @@ QQuickScrollBarAttached::QQuickScrollBarAttached(QObject *parent) Q_D(QQuickScrollBarAttached); d->setFlickable(qobject_cast<QQuickFlickable *>(parent)); - if (parent && !d->flickable) - qmlWarning(parent) << "ScrollBar must be attached to a Flickable"; + if (parent && !d->flickable && !qobject_cast<QQuickScrollView *>(parent)) + qmlWarning(parent) << "ScrollBar must be attached to a Flickable or ScrollView"; } QQuickScrollBarAttached::~QQuickScrollBarAttached() |