| qgraphicseffect.cpp |
!
\class QGraphicsEffect
\brief The QGraphicsEffect class is the base class for all graphics
effects.
\since 4.6
\ingroup multimedia
\ingroup graphicsview-api
\inmodule QtWidgets
Effects alter the appearance of elements by hooking into the rendering
pipeline and operating between the source (e.g., a QGraphicsPixmapItem)
and the destination device (e.g., QGraphicsView's viewport). Effects can be
disabled by calling setEnabled(false). If effects are disabled, the source
is rendered directly.
To add a visual effect to a QGraphicsItem, for example, you can use one of
the standard effects, or alternately, create your own effect by creating a
subclass of QGraphicsEffect. The effect can then be installed on the item
using QGraphicsItem::setGraphicsEffect().
Qt provides the following standard effects:
\list
\li QGraphicsBlurEffect - blurs the item by a given radius
\li QGraphicsDropShadowEffect - renders a dropshadow behind the item
\li QGraphicsColorizeEffect - renders the item in shades of any given color
\li QGraphicsOpacityEffect - renders the item with an opacity
\endlist
\table
\row
\li{2,1} \image graphicseffect-plain.png
{Image of a fish without any graphical effects}
\row
\li \image graphicseffect-blur.png
{Blur effect on an image of a fish}
\li \image graphicseffect-colorize.png
{Blue color effect on an image of a fish}
\row
\li \image graphicseffect-opacity.png
{Opacity effect on an image of a fish}
\li \image graphicseffect-drop-shadow.png
{Drop shadow effect on an image of a fish}
\endtable
\image graphicseffect-widget.png
{Opacity drop shadow effects applied on an application}
For more information on how to use each effect, refer to the specific
effect's documentation.
To create your own custom effect, create a subclass of QGraphicsEffect (or
any other existing effects) and reimplement the virtual function draw().
This function is called whenever the effect needs to redraw. The draw()
function takes the painter with which to draw as an argument. For more
information, refer to the documentation for draw(). In the draw() function
you can call sourcePixmap() to get a pixmap of the graphics effect source
which you can then process.
If your effect changes, use update() to request for a redraw. If your
custom effect changes the bounding rectangle of the source, e.g., a radial
glow effect may need to apply an extra margin, you can reimplement the
virtual boundingRectFor() function, and call updateBoundingRect()
to notify the framework whenever this rectangle changes. The virtual
sourceChanged() function is called to notify the effects that
the source has changed in some way - e.g., if the source is a
QGraphicsRectItem and its rectangle parameters have changed.
\sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect()
|
34506 |
- |
| qgraphicseffect.h |
|
6888 |
- |
| qgraphicseffect_p.h |
|
5987 |
- |
| qpixmapfilter.cpp |
!
\class QPixmapFilter
\since 4.5
\ingroup painting
\brief The QPixmapFilter class provides the basic functionality for
pixmap filter classes. Pixmap filter can be for example colorize or blur.
QPixmapFilter is the base class for every pixmap filter. QPixmapFilter is
an abstract class and cannot itself be instantiated. It provides a standard
interface for filter processing.
\internal
|
28552 |
- |
| qpixmapfilter_p.h |
|
4020 |
- |