Home · All Classes · All Functions · Overviews

QGraphicsEffectSource Class Reference
[
QtGui module]

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

 #include <QGraphicsEffectSource>

Inherits QObject.

This class was introduced in Qt 4.6.


Public Functions

~QGraphicsEffectSource ()
QRectF boundingRect ( Qt::CoordinateSystem system = Qt::LogicalCoordinates ) const
QRect deviceRect () const
void draw ( QPainter * painter )
const QGraphicsItem * graphicsItem () const
bool isPixmap () const
QPixmap pixmap ( Qt::CoordinateSystem system = Qt::LogicalCoordinates, QPoint * offset = 0 ) const
const QStyleOption * styleOption () const
void update ()
const QWidget * widget () const

Additional Inherited Members


Detailed Description

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

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(), QWidget::setGraphicsEffect(), and ..


Member Function Documentation

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().

QRect QGraphicsEffectSource::deviceRect () const

Returns the bounds of the current painter's device.

This function is useful when you want to draw something in device coordinates and ensure the size of the pixmap is not bigger than the size of the device.

Calling QGraphicsEffectSource::pixmap(Qt::DeviceCoordinates) always returns a pixmap which is bound to the device's size.

See also pixmap().

void QGraphicsEffectSource::draw ( QPainter * painter )

Draws the source using the given painter.

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

For example:

 MyGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
 {
     // Fully opaque; draw directly without going through a pixmap.
     if (qFuzzyCompare(m_opacity, 1)) {
         source->draw(painter);
         return;
     }
     ...
 }

See also QGraphicsEffect::draw().

const QGraphicsItem * QGraphicsEffectSource::graphicsItem () const

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

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 = 0 ) 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 returned pixmap is bound to the current painter's device rectangle when system is Qt::DeviceCoordinates.

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

const QStyleOption * QGraphicsEffectSource::styleOption () const

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

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 0.

See also graphicsItem().


Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt 4.6.0