QGraphicsEffectSource Class

The QGraphicsEffectSource class represents the source on which a QGraphicsEffect is installed on. More...

Header: #include <QGraphicsEffectSource>
Inherits: QObject

Public Functions

virtual ~QGraphicsEffectSource()
QRectF boundingRect(Qt::CoordinateSystem system = Qt::LogicalCoordinates) const
void draw(QPainter *painter)
const QGraphicsItem *graphicsItem() const
bool isPixmap() const
QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, QPoint *offset = nullptr, QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToEffectiveBoundingRect) const
const QStyleOption *styleOption() const
void update()
const QWidget *widget() const

Protected Functions

QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = nullptr)

Detailed Description

\internal

When a QGraphicsEffect is installed on a QGraphicsItem, for example, this class will act as a wrapper around QGraphicsItem. Then, calling update() is effectively the same as calling QGraphicsItem::update().

QGraphicsEffectSource also provides a pixmap() function which creates a pixmap with the source painted into it.

See also QGraphicsItem::setGraphicsEffect() and QWidget::setGraphicsEffect().

Member Function Documentation

[protected] QGraphicsEffectSource::QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = nullptr)

\internal

[virtual noexcept] QGraphicsEffectSource::~QGraphicsEffectSource()

Destroys the effect source.

QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system = Qt::LogicalCoordinates) const

Returns the bounding rectangle of the source mapped to the given system.

See also draw().

void QGraphicsEffectSource::draw(QPainter *painter)

Draws the source using the given painter.

This function should only be called from QGraphicsEffect::draw().

See also QGraphicsEffect::draw().

const QGraphicsItem *QGraphicsEffectSource::graphicsItem() const

Returns a pointer to the item if this source is a QGraphicsItem; otherwise returns nullptr.

See also widget().

bool QGraphicsEffectSource::isPixmap() const

Returns true if the source effectively is a pixmap, e.g., a QGraphicsPixmapItem.

This function is useful for optimization purposes. For instance, there's no point in drawing the source in device coordinates to avoid pixmap scaling if this function returns true - the source pixmap will be scaled anyways.

QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, QPoint *offset = nullptr, QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToEffectiveBoundingRect) const

Returns a pixmap with the source painted into it.

The system specifies which coordinate system to be used for the source. The optional offset parameter returns the offset where the pixmap should be painted at using the current painter.

The mode determines how much of the effect the pixmap will contain. By default, the pixmap will contain the whole effect.

The returned pixmap is bound to the current painter's device rectangle when system is Qt::DeviceCoordinates.

See also QGraphicsEffect::draw() and boundingRect().

const QStyleOption *QGraphicsEffectSource::styleOption() const

Returns a pointer to the style options (used when drawing the source) if available; otherwise returns nullptr.

See also graphicsItem() and widget().

void QGraphicsEffectSource::update()

Schedules a redraw of the source. Call this function whenever the source needs to be redrawn.

See also QGraphicsEffect::updateBoundingRect(), QWidget::update(), and QGraphicsItem::update().

const QWidget *QGraphicsEffectSource::widget() const

Returns a pointer to the widget if this source is a QWidget; otherwise returns nullptr.

See also graphicsItem().