Obsolete Members for QGraphicsScene

The following members of class QGraphicsScene are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

Properties

Public Functions

(obsolete) QGraphicsItem * itemAt(const QPointF & position) const
(obsolete) QGraphicsItem * itemAt(qreal x, qreal y) const
(obsolete) QList<QGraphicsItem *> items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const

Protected Functions

(obsolete) virtual void drawItems(QPainter * painter, int numItems, QGraphicsItem *[] items, const QStyleOptionGraphicsItem[] options, QWidget * widget = 0)

Property Documentation

sortCacheEnabled : bool

This property holds whether sort caching is enabled.

Since Qt 4.6, this property has no effect.

This property was introduced in Qt 4.5.

Access functions:

bool isSortCacheEnabled() const
void setSortCacheEnabled(bool enabled)

Member Function Documentation

[virtual protected] void QGraphicsScene::​drawItems(QPainter * painter, int numItems, QGraphicsItem *[] items, const QStyleOptionGraphicsItem[] options, QWidget * widget = 0)

Paints the given items using the provided painter, after the background has been drawn, and before the foreground has been drawn. All painting is done in scene coordinates. Before drawing each item, the painter must be transformed using QGraphicsItem::sceneTransform().

The options parameter is the list of style option objects for each item in items. The numItems parameter is the number of items in items and options in options. The widget parameter is optional; if specified, it should point to the widget that is being painted on.

The default implementation prepares the painter matrix, and calls QGraphicsItem::paint() on all items. Reimplement this function to provide custom painting of all items for the scene; gaining complete control over how each item is drawn. In some cases this can increase drawing performance significantly.

Example:

void CustomScene::drawItems(QPainter *painter, int numItems,
                            QGraphicsItem *items[],
                            const QStyleOptionGraphicsItem options[],
                            QWidget *widget)
{
    for (int i = 0; i < numItems; ++i) {
         // Draw the item
         painter->save();
         painter->setMatrix(items[i]->sceneMatrix(), true);
         items[i]->paint(painter, &options[i], widget);
         painter->restore();
     }
}

Since Qt 4.6, this function is not called anymore unless the QGraphicsView::IndirectPainting flag is given as an Optimization flag.

See also drawBackground() and drawForeground().

QGraphicsItem * QGraphicsScene::​itemAt(const QPointF & position) const

This is an overloaded function.

Returns the topmost visible item at the specified position, or 0 if there are no items at this position.

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

Note: See items() for a definition of which items are considered visible by this function.

See also items(), collidingItems(), and Sorting.

QGraphicsItem * QGraphicsScene::​itemAt(qreal x, qreal y) const

This is an overloaded function.

Returns the topmost visible item at the position specified by (x, y), or 0 if there are no items at this position.

This convenience function is equivalent to calling itemAt(QPointF(x, y)).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

Note: See items() for a definition of which items are considered visible by this function.

QList<QGraphicsItem *> QGraphicsScene::​items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const

This convenience function is equivalent to calling items(QRectF(x, y, w, h), mode).

This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.

This function was introduced in Qt 4.3.

© 2015 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.