mirror of https://github.com/qt/qtbase.git
Use QScroller in the Dir View example
We have never had enough examples that show how easy it is to install
a QScroller. In this case, one line makes a QTreeView flickable.
Task-number: QTBUG-86090
Change-Id: Idb8b4709617befb261f3b78d63ddbdaf5ad18d6b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit b0cd3bcec4
)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
3752ced2ca
commit
c46e2e087e
|
@ -29,7 +29,7 @@
|
||||||
\example itemviews/dirview
|
\example itemviews/dirview
|
||||||
\title Dir View Example
|
\title Dir View Example
|
||||||
\ingroup examples-itemviews
|
\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
|
The Dir View example shows a tree view of the local file
|
||||||
system. It uses the QFileSystemModel class to provide 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.
|
QTreeView object \c tree visualizes the filesystem in a tree structure.
|
||||||
|
|
||||||
\skipto tree.setAnimated(false)
|
\skipto tree.setAnimated(false)
|
||||||
\printuntil tree.setWindowTitle
|
\printuntil tree.setColumnWidth
|
||||||
|
|
||||||
Sets layout options for animation, indentation, sorting, and sizing of the
|
Sets layout options for animation, indentation, sorting, and sizing of the
|
||||||
filesystem tree.
|
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.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the examples of the Qt Toolkit.
|
** This file is part of the examples of the Qt Toolkit.
|
||||||
|
@ -52,6 +52,7 @@
|
||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
#include <QFileIconProvider>
|
#include <QFileIconProvider>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include <QScroller>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QCommandLineOption>
|
#include <QCommandLineOption>
|
||||||
|
@ -96,6 +97,9 @@ int main(int argc, char *argv[])
|
||||||
tree.resize(availableSize / 2);
|
tree.resize(availableSize / 2);
|
||||||
tree.setColumnWidth(0, tree.width() / 3);
|
tree.setColumnWidth(0, tree.width() / 3);
|
||||||
|
|
||||||
|
// Make it flickable on touchscreens
|
||||||
|
QScroller::grabGesture(&tree, QScroller::TouchGesture);
|
||||||
|
|
||||||
tree.setWindowTitle(QObject::tr("Dir View"));
|
tree.setWindowTitle(QObject::tr("Dir View"));
|
||||||
tree.show();
|
tree.show();
|
||||||
|
|
||||||
|
|
|
@ -262,8 +262,8 @@ private:
|
||||||
The scroller uses the global QAbstractAnimation timer to generate its QScrollEvents. This
|
The scroller uses the global QAbstractAnimation timer to generate its QScrollEvents. This
|
||||||
can be changed with QScrollerProperties::FrameRate on a per-QScroller basis.
|
can be changed with QScrollerProperties::FrameRate on a per-QScroller basis.
|
||||||
|
|
||||||
Several examples in the \c scroller examples directory show how QScroller,
|
The \l {Dir View Example} shows one way to use a QScroller with a QTreeView.
|
||||||
QScrollEvent and the scroller gesture can be used.
|
An example in the \c scroller examples directory also demonstrates QScroller.
|
||||||
|
|
||||||
Even though this kinetic scroller has a large number of settings available via
|
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
|
QScrollerProperties, we recommend that you leave them all at their default, platform optimized
|
||||||
|
|
Loading…
Reference in New Issue