diff options
Diffstat (limited to 'src/quicktemplates2/qquickscrollview.cpp')
-rw-r--r-- | src/quicktemplates2/qquickscrollview.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickscrollview.cpp b/src/quicktemplates2/qquickscrollview.cpp index f9f4c9f8..01e19b16 100644 --- a/src/quicktemplates2/qquickscrollview.cpp +++ b/src/quicktemplates2/qquickscrollview.cpp @@ -38,6 +38,7 @@ #include "qquickpane_p_p.h" #include "qquickscrollbar_p_p.h" +#include <QtQml/qqmlinfo.h> #include <QtQuick/private/qquickflickable_p.h> QT_BEGIN_NAMESPACE @@ -82,7 +83,13 @@ QT_BEGIN_NAMESPACE \l {QtQuick.Controls::Pane::}{contentHeight} properties must be set to the combined size of its contained items. \li If the content size is less than or equal to the size of the ScrollView, - it will not be flickable. + it will not be scrollable. + \li If you want the ScrollView to only scroll vertically, you can bind + \l {QtQuick.Controls::Pane::}{contentWidth} to + \l {QtQuick.Controls::Control::}{availableWidth} + (and vice versa for contentHeight). This will let the contents fill + out all the available space horizontally inside the ScrollView, taking + any padding or scroll bars into account. \endlist \section2 Scroll Bars @@ -569,7 +576,10 @@ void QQuickScrollView::contentItemChange(QQuickItem *newItem, QQuickItem *oldIte // assume/require that it has an explicit content size assigned. d->flickableHasExplicitContentWidth = true; d->flickableHasExplicitContentHeight = true; - d->setFlickable(qobject_cast<QQuickFlickable *>(newItem), false); + auto newItemAsFlickable = qobject_cast<QQuickFlickable *>(newItem); + if (newItem && !newItemAsFlickable) + qmlWarning(this) << "ScrollView only supports Flickable types as its contentItem"; + d->setFlickable(newItemAsFlickable, false); } QQuickPane::contentItemChange(newItem, oldItem); } |