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:
parent
9dd273027b
commit
ad0f200df5
|
@ -10,6 +10,7 @@ SUBDIRS = quick-accessibility \
|
||||||
localstorage \
|
localstorage \
|
||||||
models \
|
models \
|
||||||
views \
|
views \
|
||||||
|
tableview \
|
||||||
mousearea \
|
mousearea \
|
||||||
positioners \
|
positioners \
|
||||||
righttoleft \
|
righttoleft \
|
||||||
|
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
@ -26,7 +26,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
\title Qt Quick TableViews examples - Pixelator
|
\title Qt Quick TableViews examples - Pixelator
|
||||||
\example tableview
|
\example pixelator
|
||||||
\brief The Pixelator example shows how a QML TableView and a delegate
|
\brief The Pixelator example shows how a QML TableView and a delegate
|
||||||
can be used for custom table models.
|
can be used for custom table models.
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
\include examples-run.qdocinc
|
\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
|
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
|
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
|
We use the \l{Qt property system}{Qt Property System} and a source property
|
||||||
as \c QString to set the path of the image.
|
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.
|
Here we load the image when the source path is set.
|
||||||
When the source path has changed, we need to call \c beginResetModel() before.
|
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().
|
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.
|
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.
|
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
|
When we call this function with the display role, we return the pixel's
|
||||||
gray value.
|
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
|
We need to register our model in the QML type system to be able to use it
|
||||||
from the QML side.
|
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.
|
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
|
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
|
It also has a property for the gray value of the pixel that is retrieved
|
||||||
from the model.
|
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
|
Inside the \c Item, there is a rounded \c Rectangle with the size and
|
||||||
radius according to the pixel's gray value.
|
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
|
For a little bit of interaction, we place a \c MouseArea inside the \c Item
|
||||||
and change the Rectangle's color on mouse over.
|
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
|
The \c Rectangle also has a short color animation to fade between the
|
||||||
colors when it is changed.
|
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
|
The \c TableView spans over the whole window and has an instance of our
|
||||||
custom \c ImageModel attached.
|
custom \c ImageModel attached.
|
|
@ -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
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
@ -1,11 +1,3 @@
|
||||||
TEMPLATE = app
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
QT += quick qml
|
SUBDIRS += pixelator
|
||||||
HEADERS += imagemodel.h
|
|
||||||
SOURCES += main.cpp \
|
|
||||||
imagemodel.cpp
|
|
||||||
|
|
||||||
RESOURCES += qt.png main.qml
|
|
||||||
|
|
||||||
target.path = $$[QT_INSTALL_EXAMPLES]/quick/tableview
|
|
||||||
INSTALLS += target
|
|
||||||
|
|
Loading…
Reference in New Issue