Compatibility Members for QGraphicsItem

The following class members are part of the Qt compatibility layer. We advise against using them in new code.

Public Functions

bool acceptsHoverEvents() const
QList<QGraphicsItem *> children() const
void rotate(qreal angle)
void scale(qreal sx, qreal sy)
void setAcceptsHoverEvents(bool enabled)
void shear(qreal sh, qreal sv)
void translate(qreal dx, qreal dy)

Member Function Documentation

bool QGraphicsItem::acceptsHoverEvents() const

Call acceptHoverEvents() instead.

See also setAcceptsHoverEvents().

QList<QGraphicsItem *> QGraphicsItem::children() const

Use childItems() instead.

See also setParentItem().

void QGraphicsItem::rotate(qreal angle)

Use

setRotation(rotation() + angle);

instead.

Rotates the current item transformation angle degrees clockwise around its origin. To translate around an arbitrary point (x, y), you need to combine translation and rotation with setTransform().

Example:

// Rotate an item 45 degrees around (0, 0).
item->rotate(45);

// Rotate an item 45 degrees around (x, y).
item->setTransform(QTransform().translate(x, y).rotate(45).translate(-x, -y));

See also setTransform(), transform(), scale(), shear(), and translate().

void QGraphicsItem::scale(qreal sx, qreal sy)

Use

setTransform(QTransform::fromScale(sx, sy), true);

instead.

Scales the current item transformation by (sx, sy) around its origin. To scale from an arbitrary point (x, y), you need to combine translation and scaling with setTransform().

Example:

// Scale an item by 3x2 from its origin
item->scale(3, 2);

// Scale an item by 3x2 from (x, y)
item->setTransform(QTransform().translate(x, y).scale(3, 2).translate(-x, -y));

See also setTransform() and transform().

void QGraphicsItem::setAcceptsHoverEvents(bool enabled)

Use setAcceptHoverEvents(enabled) instead.

See also acceptsHoverEvents().

void QGraphicsItem::shear(qreal sh, qreal sv)

Use

setTransform(QTransform().shear(sh, sv), true);

instead.

Shears the current item transformation by (sh, sv).

See also setTransform() and transform().

void QGraphicsItem::translate(qreal dx, qreal dy)

Use setPos() or setTransformOriginPoint() instead. For identical behavior, use

setTransform(QTransform::fromTranslate(dx, dy), true);

Translates the current item transformation by (dx, dy).

If all you want is to move an item, you should call moveBy() or setPos() instead; this function changes the item's translation, which is conceptually separate from its position.

See also setTransform() and transform().