aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/tableview/doc/src/tableview.qdoc
diff options
context:
space:
mode:
authorMichael Winkelmann <michael.winkelmann@qt.io>2018-06-28 18:38:03 +0200
committerMitch Curtis <mitch.curtis@qt.io>2018-07-10 11:34:02 +0000
commit04e7882fc2044020f98c9f6507429a47981f222b (patch)
tree49b8c4c27f27e9673cc8dab84329e7f7e0e155c8 /examples/quick/tableview/doc/src/tableview.qdoc
parent67f0da5f285b0400bfa5aeda2d335da0668d1b27 (diff)
TableView pixelator example
Example of a QML TableView with custom table model. Inspired from the original pixelator example from the widget world. Change-Id: Ic33e6d2e9320fe135d56dde92326dd8a606fe109 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'examples/quick/tableview/doc/src/tableview.qdoc')
-rw-r--r--examples/quick/tableview/doc/src/tableview.qdoc95
1 files changed, 95 insertions, 0 deletions
diff --git a/examples/quick/tableview/doc/src/tableview.qdoc b/examples/quick/tableview/doc/src/tableview.qdoc
new file mode 100644
index 0000000000..e0d9200730
--- /dev/null
+++ b/examples/quick/tableview/doc/src/tableview.qdoc
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+ \title Qt Quick TableViews examples - Pixelator
+ \example tableview
+ \brief The Pixelator example shows how a QML TableView and a delegate
+ can be used for custom table models.
+
+ \image qt-pixelator.png
+ \ingroup qtquickexamples
+
+ \include examples-run.qdocinc
+
+ \snippet tableview/imagemodel.h model
+
+ We only require a simple, read-only table model. Thus, we need to implement
+ functions to indicate the dimensions of the image and supply data to the
+ TableView.
+ We use the \l{Qt property system}{Qt Property System} and a source property
+ as \c QString to set the path of the image.
+
+ \snippet tableview/imagemodel.cpp setsource
+
+ Here we load the image when the source path is set.
+ When the source path has changed, we need to call \c beginResetModel() before.
+ After the image has been loaded, we need to call \c endResetModel().
+
+ \snippet tableview/imagemodel.cpp rowcolcount
+
+ The row and column count is set to image height and width, respectively.
+
+ \snippet tableview/imagemodel.cpp data
+
+ This overloaded function allows us to access the pixel data from the image.
+ When we call this function with the display role, we return the pixel's
+ gray value.
+
+ \snippet tableview/main.cpp registertype
+
+ We need to register our model in the QML type system to be able to use it
+ from the QML side.
+
+ \snippet tableview/main.qml pixelcomponent
+
+ Each pixel in the \c TableView is displayed via a delegate component.
+ It contains an item that has an implicit height and width defining the
+ cell size of the table.
+ It also has a property for the gray value of the pixel that is retrieved
+ from the model.
+
+ \snippet tableview/main.qml rectshape
+
+ Inside the \c Item, there is a rounded \c Rectangle with the size and
+ radius according to the pixel's gray value.
+
+ \snippet tableview/main.qml interaction
+
+ For a little bit of interaction, we place a \c MouseArea inside the \c Item
+ and change the Rectangle's color on mouse over.
+
+ \snippet tableview/main.qml animation
+
+ The \c Rectangle also has a short color animation to fade between the
+ colors when it is changed.
+
+ \snippet tableview/main.qml tableview
+
+ The \c TableView spans over the whole window and has an instance of our
+ custom \c ImageModel attached.
+
+*/