diff --git a/examples/quick/quick.pro b/examples/quick/quick.pro index ede3c54728..deef437046 100644 --- a/examples/quick/quick.pro +++ b/examples/quick/quick.pro @@ -10,6 +10,7 @@ SUBDIRS = quick-accessibility \ localstorage \ models \ views \ + tableview \ mousearea \ positioners \ righttoleft \ diff --git a/examples/quick/tableview/doc/images/qt-pixelator.png b/examples/quick/tableview/pixelator/doc/images/qt-pixelator.png similarity index 100% rename from examples/quick/tableview/doc/images/qt-pixelator.png rename to examples/quick/tableview/pixelator/doc/images/qt-pixelator.png diff --git a/examples/quick/tableview/doc/src/tableview.qdoc b/examples/quick/tableview/pixelator/doc/src/pixelator.qdoc similarity index 87% rename from examples/quick/tableview/doc/src/tableview.qdoc rename to examples/quick/tableview/pixelator/doc/src/pixelator.qdoc index e0d9200730..4f8d519060 100644 --- a/examples/quick/tableview/doc/src/tableview.qdoc +++ b/examples/quick/tableview/pixelator/doc/src/pixelator.qdoc @@ -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. diff --git a/examples/quick/tableview/imagemodel.cpp b/examples/quick/tableview/pixelator/imagemodel.cpp similarity index 100% rename from examples/quick/tableview/imagemodel.cpp rename to examples/quick/tableview/pixelator/imagemodel.cpp diff --git a/examples/quick/tableview/imagemodel.h b/examples/quick/tableview/pixelator/imagemodel.h similarity index 100% rename from examples/quick/tableview/imagemodel.h rename to examples/quick/tableview/pixelator/imagemodel.h diff --git a/examples/quick/tableview/main.cpp b/examples/quick/tableview/pixelator/main.cpp similarity index 100% rename from examples/quick/tableview/main.cpp rename to examples/quick/tableview/pixelator/main.cpp diff --git a/examples/quick/tableview/main.qml b/examples/quick/tableview/pixelator/main.qml similarity index 100% rename from examples/quick/tableview/main.qml rename to examples/quick/tableview/pixelator/main.qml diff --git a/examples/quick/tableview/pixelator/pixelator.pro b/examples/quick/tableview/pixelator/pixelator.pro new file mode 100644 index 0000000000..6c863cb304 --- /dev/null +++ b/examples/quick/tableview/pixelator/pixelator.pro @@ -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 diff --git a/examples/quick/tableview/qt.png b/examples/quick/tableview/pixelator/qt.png similarity index 100% rename from examples/quick/tableview/qt.png rename to examples/quick/tableview/pixelator/qt.png diff --git a/examples/quick/tableview/tableview.pro b/examples/quick/tableview/tableview.pro index ea8e3bd12b..2bcd119c31 100644 --- a/examples/quick/tableview/tableview.pro +++ b/examples/quick/tableview/tableview.pro @@ -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