summaryrefslogtreecommitdiffstats
path: root/examples/widgets/doc/pixelator.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/doc/pixelator.qdoc')
-rw-r--r--examples/widgets/doc/pixelator.qdoc56
1 files changed, 28 insertions, 28 deletions
diff --git a/examples/widgets/doc/pixelator.qdoc b/examples/widgets/doc/pixelator.qdoc
index 099c382c82..a44feb61fc 100644
--- a/examples/widgets/doc/pixelator.qdoc
+++ b/examples/widgets/doc/pixelator.qdoc
@@ -26,7 +26,7 @@
****************************************************************************/
/*!
- \example itemviews/pixelator
+ \example widgets/itemviews/pixelator
\title Pixelator Example
The Pixelator example shows how delegates can be used to customize the way that
@@ -60,7 +60,7 @@
The \c ImageModel class is defined as follows:
- \snippet itemviews/pixelator/imagemodel.h 0
+ \snippet widgets/itemviews/pixelator/imagemodel.h 0
Since we only require a simple, read-only table model, we only need to implement
functions to indicate the dimensions of the image and supply data to other
@@ -70,11 +70,11 @@
The constructor is trivial:
- \snippet itemviews/pixelator/imagemodel.cpp 0
+ \snippet widgets/itemviews/pixelator/imagemodel.cpp 0
The \c setImage() function sets the image that will be used by the model:
- \snippet itemviews/pixelator/imagemodel.cpp 1
+ \snippet widgets/itemviews/pixelator/imagemodel.cpp 1
The QAbstractItemModel::reset() call tells the view(s) that the model
has changed.
@@ -82,8 +82,8 @@
The \c rowCount() and \c columnCount() functions return the height and width of
the image respectively:
- \snippet itemviews/pixelator/imagemodel.cpp 2
- \snippet itemviews/pixelator/imagemodel.cpp 3
+ \snippet widgets/itemviews/pixelator/imagemodel.cpp 2
+ \snippet widgets/itemviews/pixelator/imagemodel.cpp 3
Since the image is a simple two-dimensional structure, the \c parent arguments
to these functions are unused. They both simply return the relevant size from
@@ -92,7 +92,7 @@
The \c data() function returns data for the item that corresponds to a given
model index in a format that is suitable for a particular role:
- \snippet itemviews/pixelator/imagemodel.cpp 4
+ \snippet widgets/itemviews/pixelator/imagemodel.cpp 4
In this implementation, we only check that the model index is valid, and that
the role requested is the \l{Qt::ItemDataRole}{DisplayRole}. If so, the function
@@ -105,7 +105,7 @@
The \c headerData() function is also reimplemented:
- \snippet itemviews/pixelator/imagemodel.cpp 5
+ \snippet widgets/itemviews/pixelator/imagemodel.cpp 5
We return (1, 1) as the size hint for a header item. If we
didn't, the headers would default to a larger size, preventing
@@ -116,7 +116,7 @@
The \c PixelDelegate class is defined as follows:
- \snippet itemviews/pixelator/pixeldelegate.h 0
+ \snippet widgets/itemviews/pixelator/pixeldelegate.h 0
This class provides only basic features for a delegate so, unlike the
\l{Spin Box Delegate Example}{Spin Box Delegate} example, we subclass
@@ -134,7 +134,7 @@
also called to ensure that the delegate is set up with a parent object,
if one is supplied:
- \snippet itemviews/pixelator/pixeldelegate.cpp 0
+ \snippet widgets/itemviews/pixelator/pixeldelegate.cpp 0
Each item is rendered by the delegate's
\l{QAbstractItemDelegate::paint()}{paint()} function. The view calls this
@@ -142,7 +142,7 @@
delegate should use to correctly draw the item, and an index to the item in
the model:
- \snippet itemviews/pixelator/pixeldelegate.cpp 1
+ \snippet widgets/itemviews/pixelator/pixeldelegate.cpp 1
The first task the delegate has to perform is to draw the item's background
correctly. Usually, selected items appear differently to non-selected items,
@@ -151,8 +151,8 @@
The radius of each circle is calculated in the following lines of code:
- \snippet itemviews/pixelator/pixeldelegate.cpp 3
- \snippet itemviews/pixelator/pixeldelegate.cpp 4
+ \snippet widgets/itemviews/pixelator/pixeldelegate.cpp 3
+ \snippet widgets/itemviews/pixelator/pixeldelegate.cpp 4
First, the largest possible radius of the circle is determined by taking the
smallest dimension of the style option's \c rect attribute.
@@ -161,22 +161,22 @@
scaling the brightness to fit within the item and subtracting it from the
largest possible radius.
- \snippet itemviews/pixelator/pixeldelegate.cpp 5
- \snippet itemviews/pixelator/pixeldelegate.cpp 6
- \snippet itemviews/pixelator/pixeldelegate.cpp 7
+ \snippet widgets/itemviews/pixelator/pixeldelegate.cpp 5
+ \snippet widgets/itemviews/pixelator/pixeldelegate.cpp 6
+ \snippet widgets/itemviews/pixelator/pixeldelegate.cpp 7
We save the painter's state, turn on antialiasing (to obtain smoother
curves), and turn off the pen.
- \snippet itemviews/pixelator/pixeldelegate.cpp 8
- \snippet itemviews/pixelator/pixeldelegate.cpp 9
+ \snippet widgets/itemviews/pixelator/pixeldelegate.cpp 8
+ \snippet widgets/itemviews/pixelator/pixeldelegate.cpp 9
The foreground of the item (the circle representing a pixel) must be
rendered using an appropriate brush. For unselected items, we will use a
solid black brush; selected items are drawn using a predefined brush from
the style option's palette.
- \snippet itemviews/pixelator/pixeldelegate.cpp 10
+ \snippet widgets/itemviews/pixelator/pixeldelegate.cpp 10
Finally, we paint the circle within the rectangle specified by the style
option and we call \l{QPainter::}{restore()} on the painter.
@@ -191,12 +191,12 @@
returns a size for the item based on the predefined pixel size, initially set
up in the constructor:
- \snippet itemviews/pixelator/pixeldelegate.cpp 11
+ \snippet widgets/itemviews/pixelator/pixeldelegate.cpp 11
The delegate's size is updated whenever the pixel size is changed.
We provide a custom slot to do this:
- \snippet itemviews/pixelator/pixeldelegate.cpp 12
+ \snippet widgets/itemviews/pixelator/pixeldelegate.cpp 12
\section1 Using The Custom Delegate
@@ -210,9 +210,9 @@
In the constructor, we set up a table view, turn off its grid, and hide its
headers:
- \snippet itemviews/pixelator/mainwindow.cpp 0
+ \snippet widgets/itemviews/pixelator/mainwindow.cpp 0
\dots
- \snippet itemviews/pixelator/mainwindow.cpp 1
+ \snippet widgets/itemviews/pixelator/mainwindow.cpp 1
This enables the items to be drawn without any gaps between them. Removing
the headers also prevents the user from adjusting the sizes of individual
@@ -226,7 +226,7 @@
The custom delegate is constructed with the main window as its parent, so
that it will be deleted correctly later, and we set it on the table view.
- \snippet itemviews/pixelator/mainwindow.cpp 2
+ \snippet widgets/itemviews/pixelator/mainwindow.cpp 2
Each item in the table view will be rendered by the \c PixelDelegate
instance.
@@ -234,21 +234,21 @@
We construct a spin box to allow the user to change the size of each "pixel"
drawn by the delegate:
- \snippet itemviews/pixelator/mainwindow.cpp 3
+ \snippet widgets/itemviews/pixelator/mainwindow.cpp 3
This spin box is connected to the custom slot we implemented in the
\c PixelDelegate class. This ensures that the delegate always draws each
pixel at the currently specified size:
- \snippet itemviews/pixelator/mainwindow.cpp 4
+ \snippet widgets/itemviews/pixelator/mainwindow.cpp 4
\dots
- \snippet itemviews/pixelator/mainwindow.cpp 5
+ \snippet widgets/itemviews/pixelator/mainwindow.cpp 5
We also connect the spin box to a slot in the \c MainWindow class. This
forces the view to take into account the new size hints for each item;
these are provided by the delegate in its \c sizeHint() function.
- \snippet itemviews/pixelator/mainwindow.cpp 6
+ \snippet widgets/itemviews/pixelator/mainwindow.cpp 6
We explicitly resize the columns and rows to match the
\uicontrol{Pixel size} combobox.