QPixmapDropShadowFilter Class
The QPixmapDropShadowFilter class is a convenience class for drawing pixmaps with drop shadows. More...
Header: | #include <QPixmapDropShadowFilter> |
Inherits: | QPixmapFilter |
Public Functions
QPixmapDropShadowFilter(QObject *parent = nullptr) | |
virtual | ~QPixmapDropShadowFilter() |
qreal | blurRadius() const |
QColor | color() const |
QPointF | offset() const |
void | setBlurRadius(qreal radius) |
void | setColor(const QColor &color) |
void | setOffset(const QPointF &offset) |
Reimplemented Public Functions
virtual QRectF | boundingRectFor(const QRectF &rect) const override |
virtual void | draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src = QRectF()) const override |
Detailed Description
\since
4.5 \ingroup
painting
The drop shadow is produced by taking a copy of the source pixmap and applying a color to the copy using a QPainter::CompositionMode_DestinationIn operation. This produces a homogeneously-colored pixmap which is then drawn using a QPixmapConvolutionFilter at an offset. The original pixmap is drawn on top.
The QPixmapDropShadowFilter class provides some customization options to specify how the drop shadow should appear. The color of the drop shadow can be modified using the setColor() function, the drop shadow offset can be modified using the setOffset() function, and the blur radius of the drop shadow can be changed through the setBlurRadius() function.
By default, the drop shadow is a dark gray shadow, blurred with a radius of 1 at an offset of 8 pixels towards the lower right.
Example:
QPixmapDropShadowFilter *myFilter = new QPixmapDropShadowFilter; myFilter->draw(painter, QPoint(0, 0), originalPixmap);
\internal
See also QPixmapColorizeFilter and QPixmapConvolutionFilter.
Member Function Documentation
QPixmapDropShadowFilter::QPixmapDropShadowFilter(QObject *parent = nullptr)
Constructs drop shadow filter.
\internal
[virtual noexcept]
QPixmapDropShadowFilter::~QPixmapDropShadowFilter()
Destroys drop shadow filter.
\internal
qreal QPixmapDropShadowFilter::blurRadius() const
Returns the radius in pixels of the blur on the drop shadow.
A smaller radius results in a sharper shadow.
\internal
See also setBlurRadius(), color(), and offset().
[override virtual]
QRectF QPixmapDropShadowFilter::boundingRectFor(const QRectF &rect) const
Reimplements: QPixmapFilter::boundingRectFor(const QRectF &rect) const.
\internal
QColor QPixmapDropShadowFilter::color() const
Returns the color of the drop shadow.
\internal
See also setColor(), blurRadius(), and offset().
[override virtual]
void QPixmapDropShadowFilter::draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src = QRectF()) const
\internal
QPointF QPixmapDropShadowFilter::offset() const
Returns the shadow offset in pixels.
\internal
See also setOffset(), blurRadius(), and color().
void QPixmapDropShadowFilter::setBlurRadius(qreal radius)
Sets the radius in pixels of the blur on the drop shadow to the radius specified.
Using a smaller radius results in a sharper shadow.
\internal
See also blurRadius(), setColor(), and setOffset().
void QPixmapDropShadowFilter::setColor(const QColor &color)
Sets the color of the drop shadow to the color specified.
\internal
See also color(), setBlurRadius(), and setOffset().
void QPixmapDropShadowFilter::setOffset(const QPointF &offset)
Sets the shadow offset in pixels to the offset specified.
\internal
See also offset(), setBlurRadius(), and setColor().