Make a subdirectory for TableView examples

This makes more room for more tableview examples.
I also added the tableview directory to the quick.pro subdirs.

Change-Id: Ia136150ded99c2ec627e122aa676e24a519683a9
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Michael Winkelmann 2018-07-11 10:58:34 +02:00 committed by hjk
parent 9dd273027b
commit ad0f200df5
10 changed files with 25 additions and 21 deletions

View File

@ -10,6 +10,7 @@ SUBDIRS = quick-accessibility \
localstorage \
models \
views \
tableview \
mousearea \
positioners \
righttoleft \

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -26,7 +26,7 @@
****************************************************************************/
/*!
\title Qt Quick TableViews examples - Pixelator
\example tableview
\example pixelator
\brief The Pixelator example shows how a QML TableView and a delegate
can be used for custom table models.
@ -35,7 +35,7 @@
\include examples-run.qdocinc
\snippet tableview/imagemodel.h model
\snippet pixelator/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
@ -43,28 +43,28 @@
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
\snippet pixelator/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
\snippet pixelator/imagemodel.cpp rowcolcount
The row and column count is set to image height and width, respectively.
\snippet tableview/imagemodel.cpp data
\snippet pixelator/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
\snippet pixelator/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
\snippet pixelator/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
@ -72,22 +72,22 @@
It also has a property for the gray value of the pixel that is retrieved
from the model.
\snippet tableview/main.qml rectshape
\snippet pixelator/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
\snippet pixelator/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
\snippet pixelator/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
\snippet pixelator/main.qml tableview
The \c TableView spans over the whole window and has an instance of our
custom \c ImageModel attached.

View File

@ -0,0 +1,11 @@
TEMPLATE = app
QT += quick qml
HEADERS += imagemodel.h
SOURCES += main.cpp \
imagemodel.cpp
RESOURCES += qt.png main.qml
target.path = $$[QT_INSTALL_EXAMPLES]/quick/tableview/pixelator
INSTALLS += target

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -1,11 +1,3 @@
TEMPLATE = app
TEMPLATE = subdirs
QT += quick qml
HEADERS += imagemodel.h
SOURCES += main.cpp \
imagemodel.cpp
RESOURCES += qt.png main.qml
target.path = $$[QT_INSTALL_EXAMPLES]/quick/tableview
INSTALLS += target
SUBDIRS += pixelator