diff options
-rw-r--r-- | src/imports/controls/doc/snippets/qtquickcontrols2-scrollview.qml | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquickscrollview.cpp | 19 | ||||
-rw-r--r-- | tests/manual/nativestyle/main.qml | 2 |
3 files changed, 14 insertions, 8 deletions
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview.qml index dce07b39..c96ae1ed 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-scrollview.qml @@ -50,7 +50,6 @@ Rectangle { ScrollView { width: 200 height: 200 - clip: true Label { text: "ABC" diff --git a/src/quicktemplates2/qquickscrollview.cpp b/src/quicktemplates2/qquickscrollview.cpp index f9f4c9f8..f295ee30 100644 --- a/src/quicktemplates2/qquickscrollview.cpp +++ b/src/quicktemplates2/qquickscrollview.cpp @@ -61,15 +61,16 @@ QT_BEGIN_NAMESPACE \snippet qtquickcontrols2-scrollview.qml file - \note ScrollView does not automatically clip its contents. If it is not used as - a full-screen item, you should consider setting the \l {Item::}{clip} property - to \c true, as shown above. - The second example illustrates using an existing \l Flickable, that is, a \l ListView. \snippet qtquickcontrols2-scrollview-listview.qml file + \note As of Qt-6.0, ScrollView automatically clips its contents if you + don't use a Flickable as a child. If this is not wanted, you can + set your own Flickable as a child, and control the \l {Item::}{clip} + property on the Flickable explicitly. + \section2 Sizing As with Flickable, there are several things to keep in mind when using @@ -180,7 +181,15 @@ QQuickFlickable *QQuickScrollViewPrivate::ensureFlickable(bool content) if (!flickable) { flickableHasExplicitContentWidth = false; flickableHasExplicitContentHeight = false; - setFlickable(new QQuickFlickable(q), content); + auto flickable = new QQuickFlickable(q); + // We almost always want to clip the flickable so that flickable + // contents doesn't show up outside the scrollview. The only time + // this is not really needed, is when the scrollview covers the whole + // window and the scrollbars are transient. But for that corner case, if this + // optimization is needed, the user can simply create his own flickable + // child inside the scrollview, and control clipping on it explicit. + flickable->setClip(true); + setFlickable(flickable, content); } return flickable; } diff --git a/tests/manual/nativestyle/main.qml b/tests/manual/nativestyle/main.qml index 5e75e7a3..c1f02411 100644 --- a/tests/manual/nativestyle/main.qml +++ b/tests/manual/nativestyle/main.qml @@ -71,7 +71,6 @@ ApplicationWindow { ScrollView { contentWidth: width - ScrollBar.vertical.width - clip: true Column { anchors.left: parent.left @@ -97,7 +96,6 @@ ApplicationWindow { ScrollView { contentWidth: width - ScrollBar.vertical.width - clip: true Column { anchors.left: parent.left |