QGraphicsSceneIndex Class
The QGraphicsSceneIndex class provides a base class to implement a custom indexing algorithm for discovering items in QGraphicsScene. \since
4.6 \ingroup
graphicsview-api. More...
Header: | #include <QGraphicsSceneIndex> |
Inherits: | QObject |
Inherited By: |
Public Functions
QGraphicsSceneIndex(QGraphicsScene *scene = nullptr) | |
virtual | ~QGraphicsSceneIndex() |
virtual QList<QGraphicsItem *> | estimateItems(const QPointF &point, Qt::SortOrder order) const |
QGraphicsScene * | scene() const |
Protected Functions
QGraphicsSceneIndex(QGraphicsSceneIndexPrivate &dd, QGraphicsScene *scene) | |
virtual void | clear() |
virtual void | deleteItem(QGraphicsItem *item) |
virtual void | itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value) |
virtual void | prepareBoundingRectChange(const QGraphicsItem *item) |
Protected Slots
virtual void | updateSceneRect(const QRectF &rect) |
Detailed Description
\internal
The QGraphicsSceneIndex class provides a base class to implement a custom indexing algorithm for discovering items in QGraphicsScene. You need to subclass it and reimplement addItem, removeItem, estimateItems and items in order to have an functional indexing.
See also QGraphicsScene and QGraphicsView.
Member Function Documentation
QGraphicsSceneIndex::QGraphicsSceneIndex(QGraphicsScene *scene = nullptr)
Constructs an abstract scene index for a given scene.
[protected]
QGraphicsSceneIndex::QGraphicsSceneIndex(QGraphicsSceneIndexPrivate &dd, QGraphicsScene *scene)
\internal
[virtual noexcept]
QGraphicsSceneIndex::~QGraphicsSceneIndex()
Destroys the scene index.
[virtual protected]
void QGraphicsSceneIndex::clear()
This virtual function removes all items in the scene index.
[virtual protected]
void QGraphicsSceneIndex::deleteItem(QGraphicsItem *item)
This method is called when an item has been deleted. The default implementation calls removeItem. Be careful, if your implementation of removeItem use pure virtual method of QGraphicsItem like boundingRect(), then you should reimplement this method.
See also addItem() and removeItem().
[virtual]
QList<QGraphicsItem *> QGraphicsSceneIndex::estimateItems(const QPointF &point, Qt::SortOrder order) const
This virtual function return an estimation of items at position point. This method return a list sorted using order.
[virtual protected]
void QGraphicsSceneIndex::itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value)
This virtual function is called by QGraphicsItem to notify the index that some part of the item 's state changes. By reimplementing this function, your can react to a change, and in some cases, (depending on change,) adjustments in the index can be made.
change is the parameter of the item that is changing. value is the value that changed; the type of the value depends on change.
The default implementation does nothing.
See also QGraphicsItem::GraphicsItemChange.
[virtual protected]
void QGraphicsSceneIndex::prepareBoundingRectChange(const QGraphicsItem *item)
Notify the index for a geometry change of an item.
See also QGraphicsItem::prepareGeometryChange().
QGraphicsScene *QGraphicsSceneIndex::scene() const
Returns the scene of this index.
[virtual protected slot]
void QGraphicsSceneIndex::updateSceneRect(const QRectF &rect)
Notifies the index that the scene's scene rect has changed. rect is thew new scene rect.
See also QGraphicsScene::sceneRect().