diff --git a/examples/widgets/doc/src/dirview.qdoc b/examples/widgets/doc/src/dirview.qdoc index 6db339eced..d8c68bf41e 100644 --- a/examples/widgets/doc/src/dirview.qdoc +++ b/examples/widgets/doc/src/dirview.qdoc @@ -29,7 +29,7 @@ \example itemviews/dirview \title Dir View Example \ingroup examples-itemviews - \brief This example demonstrates the usage of a tree view. + \brief This example demonstrates the usage of a tree view, and smooth flicking on a touchscreen. The Dir View example shows a tree view of the local file system. It uses the QFileSystemModel class to provide file @@ -60,8 +60,14 @@ QTreeView object \c tree visualizes the filesystem in a tree structure. \skipto tree.setAnimated(false) - \printuntil tree.setWindowTitle + \printuntil tree.setColumnWidth Sets layout options for animation, indentation, sorting, and sizing of the filesystem tree. + + \skipto QScroller::grabGesture + \printuntil QScroller::grabGesture + + Creates a \l QScroller instance to recognize gestures on touchscreens, + so that you can flick the tree view with your finger. */ diff --git a/examples/widgets/itemviews/dirview/main.cpp b/examples/widgets/itemviews/dirview/main.cpp index fcdf4c7ba4..20e5d45c95 100644 --- a/examples/widgets/itemviews/dirview/main.cpp +++ b/examples/widgets/itemviews/dirview/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -96,6 +97,9 @@ int main(int argc, char *argv[]) tree.resize(availableSize / 2); tree.setColumnWidth(0, tree.width() / 3); + // Make it flickable on touchscreens + QScroller::grabGesture(&tree, QScroller::TouchGesture); + tree.setWindowTitle(QObject::tr("Dir View")); tree.show(); diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index b94d8f4b81..ec679293bc 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -260,8 +260,8 @@ private: The scroller uses the global QAbstractAnimation timer to generate its QScrollEvents. This can be changed with QScrollerProperties::FrameRate on a per-QScroller basis. - Several examples in the \c scroller examples directory show how QScroller, - QScrollEvent and the scroller gesture can be used. + The \l {Dir View Example} shows one way to use a QScroller with a QTreeView. + An example in the \c scroller examples directory also demonstrates QScroller. Even though this kinetic scroller has a large number of settings available via QScrollerProperties, we recommend that you leave them all at their default, platform optimized