QtBase  v6.3.1
Public Member Functions | Protected Slots | Protected Member Functions | Friends | List of all members
QGraphicsSceneIndex Class Referenceabstract

The QGraphicsSceneIndex class provides a base class to implement a custom indexing algorithm for discovering items in QGraphicsScene. More...

#include <qgraphicssceneindex_p.h>

Inheritance diagram for QGraphicsSceneIndex:
Inheritance graph
[legend]
Collaboration diagram for QGraphicsSceneIndex:
Collaboration graph
[legend]

Public Member Functions

 QGraphicsSceneIndex (QGraphicsScene *scene=nullptr)
 
virtual ~QGraphicsSceneIndex ()
 
QGraphicsScenescene () const
 
virtual QList< QGraphicsItem * > items (Qt::SortOrder order=Qt::DescendingOrder) const =0
 
virtual QList< QGraphicsItem * > items (const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const
 
virtual QList< QGraphicsItem * > items (const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const
 
virtual QList< QGraphicsItem * > items (const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const
 
virtual QList< QGraphicsItem * > items (const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const
 
virtual QList< QGraphicsItem * > estimateItems (const QPointF &point, Qt::SortOrder order) const
 
virtual QList< QGraphicsItem * > estimateItems (const QRectF &rect, Qt::SortOrder order) const =0
 
virtual QList< QGraphicsItem * > estimateTopLevelItems (const QRectF &, Qt::SortOrder order) const
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 

Protected Slots

virtual void updateSceneRect (const QRectF &rect)
 

Protected Member Functions

virtual void clear ()
 
virtual void addItem (QGraphicsItem *item)=0
 
virtual void removeItem (QGraphicsItem *item)=0
 
virtual void deleteItem (QGraphicsItem *item)
 
virtual void itemChange (const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange, const void *const value)
 
virtual void prepareBoundingRectChange (const QGraphicsItem *item)
 
 QGraphicsSceneIndex (QGraphicsSceneIndexPrivate &dd, QGraphicsScene *scene)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Friends

class QGraphicsScene
 
class QGraphicsScenePrivate
 
class QGraphicsItem
 
class QGraphicsItemPrivate
 
class QGraphicsSceneBspTreeIndex
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Detailed Description

The QGraphicsSceneIndex class provides a base class to implement a custom indexing algorithm for discovering items in QGraphicsScene.

Since
4.6

Definition at line 74 of file qgraphicssceneindex_p.h.

Constructor & Destructor Documentation

◆ QGraphicsSceneIndex() [1/2]

QGraphicsSceneIndex::QGraphicsSceneIndex ( QGraphicsScene scene = nullptr)

Constructs an abstract scene index for a given scene.

Definition at line 348 of file qgraphicssceneindex.cpp.

◆ ~QGraphicsSceneIndex()

QGraphicsSceneIndex::~QGraphicsSceneIndex ( )
virtual

Destroys the scene index.

Definition at line 366 of file qgraphicssceneindex.cpp.

◆ QGraphicsSceneIndex() [2/2]

QGraphicsSceneIndex::QGraphicsSceneIndex ( QGraphicsSceneIndexPrivate dd,
QGraphicsScene scene 
)
protected

Definition at line 357 of file qgraphicssceneindex.cpp.

Member Function Documentation

◆ addItem()

void QGraphicsSceneIndex::addItem ( QGraphicsItem item)
protectedpure virtual

This pure virtual function inserts an item to the scene index.

See also
removeItem(), deleteItem()

Implemented in QGraphicsSceneLinearIndex, and QGraphicsSceneBspTreeIndex.

◆ clear()

void QGraphicsSceneIndex::clear ( )
protectedvirtual

This virtual function removes all items in the scene index.

Reimplemented in QGraphicsSceneLinearIndex, and QGraphicsSceneBspTreeIndex.

Definition at line 559 of file qgraphicssceneindex.cpp.

Here is the call graph for this function:

◆ deleteItem()

void QGraphicsSceneIndex::deleteItem ( QGraphicsItem item)
protectedvirtual

This method is called when an item has been deleted. The default implementation call removeItem. Be carefull, if your implementation of removeItem use pure virtual method of QGraphicsItem like boundingRect(), then you should reimplement this method.

See also
addItem(), removeItem()

Definition at line 591 of file qgraphicssceneindex.cpp.

Here is the call graph for this function:

◆ estimateItems() [1/2]

QList< QGraphicsItem * > QGraphicsSceneIndex::estimateItems ( const QPointF point,
Qt::SortOrder  order 
) const
virtual

This virtual function return an estimation of items at position point. This method return a list sorted using order.

Definition at line 515 of file qgraphicssceneindex.cpp.

◆ estimateItems() [2/2]

virtual QList<QGraphicsItem *> QGraphicsSceneIndex::estimateItems ( const QRectF rect,
Qt::SortOrder  order 
) const
pure virtual

◆ estimateTopLevelItems()

QList< QGraphicsItem * > QGraphicsSceneIndex::estimateTopLevelItems ( const QRectF rect,
Qt::SortOrder  order 
) const
virtual

Reimplemented in QGraphicsSceneBspTreeIndex.

Definition at line 520 of file qgraphicssceneindex.cpp.

Here is the call graph for this function:

◆ itemChange()

void QGraphicsSceneIndex::itemChange ( const QGraphicsItem item,
QGraphicsItem::GraphicsItemChange  change,
const void *const  value 
)
protectedvirtual

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

Reimplemented in QGraphicsSceneBspTreeIndex.

Definition at line 609 of file qgraphicssceneindex.cpp.

Here is the call graph for this function:

◆ items() [1/5]

QList< QGraphicsItem * > QGraphicsSceneIndex::items ( const QPainterPath path,
Qt::ItemSelectionMode  mode,
Qt::SortOrder  order,
const QTransform deviceTransform = QTransform() 
) const
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns all visible items that, depending on mode, are either inside or intersect with the specified path and return a list sorted using order.

The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by path are returned.

deviceTransform is the transformation apply to the view.

This method use the estimation of the index (estimateItems) and refine the list to get an exact result. If you want to implement your own refinement algorithm you can reimplement this method.

See also
estimateItems()

Definition at line 500 of file qgraphicssceneindex.cpp.

◆ items() [2/5]

QList< QGraphicsItem * > QGraphicsSceneIndex::items ( const QPointF pos,
Qt::ItemSelectionMode  mode,
Qt::SortOrder  order,
const QTransform deviceTransform = QTransform() 
) const
virtual

Returns all visible items that, depending on mode, are at the specified pos and return a list sorted using order.

The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with pos are returned.

deviceTransform is the transformation apply to the view.

This method use the estimation of the index (estimateItems) and refine the list to get an exact result. If you want to implement your own refinement algorithm you can reimplement this method.

See also
estimateItems()

Definition at line 400 of file qgraphicssceneindex.cpp.

◆ items() [3/5]

QList< QGraphicsItem * > QGraphicsSceneIndex::items ( const QPolygonF polygon,
Qt::ItemSelectionMode  mode,
Qt::SortOrder  order,
const QTransform deviceTransform = QTransform() 
) const
virtual

Definition at line 465 of file qgraphicssceneindex.cpp.

◆ items() [4/5]

QList< QGraphicsItem * > QGraphicsSceneIndex::items ( const QRectF rect,
Qt::ItemSelectionMode  mode,
Qt::SortOrder  order,
const QTransform deviceTransform = QTransform() 
) const
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns all visible items that, depending on mode, are either inside or intersect with the specified rect and return a list sorted using order.

The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by rect are returned.

deviceTransform is the transformation apply to the view.

This method use the estimation of the index (estimateItems) and refine the list to get an exact result. If you want to implement your own refinement algorithm you can reimplement this method.

See also
estimateItems()

Definition at line 432 of file qgraphicssceneindex.cpp.

◆ items() [5/5]

QList< QGraphicsItem * > QGraphicsSceneIndex::items ( Qt::SortOrder  order = Qt::DescendingOrder) const
pure virtual

This pure virtual function all items in the index and sort them using order.

Implemented in QGraphicsSceneLinearIndex, and QGraphicsSceneBspTreeIndex.

Here is the caller graph for this function:

◆ prepareBoundingRectChange()

void QGraphicsSceneIndex::prepareBoundingRectChange ( const QGraphicsItem item)
protectedvirtual

Notify the index for a geometry change of an item.

See also
QGraphicsItem::prepareGeometryChange()

Reimplemented in QGraphicsSceneBspTreeIndex.

Definition at line 621 of file qgraphicssceneindex.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeItem()

void QGraphicsSceneIndex::removeItem ( QGraphicsItem item)
protectedpure virtual

This pure virtual function removes an item to the scene index.

See also
addItem(), deleteItem()

Implemented in QGraphicsSceneLinearIndex, and QGraphicsSceneBspTreeIndex.

Here is the caller graph for this function:

◆ scene()

QGraphicsScene * QGraphicsSceneIndex::scene ( ) const

Returns the scene of this index.

Definition at line 374 of file qgraphicssceneindex.cpp.

◆ updateSceneRect

void QGraphicsSceneIndex::updateSceneRect ( const QRectF rect)
protectedvirtualslot

Notifies the index that the scene's scene rect has changed. rect is thew new scene rect.

See also
QGraphicsScene::sceneRect()

Definition at line 551 of file qgraphicssceneindex.cpp.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ QGraphicsItem

friend class QGraphicsItem
friend

Definition at line 113 of file qgraphicssceneindex_p.h.

◆ QGraphicsItemPrivate

friend class QGraphicsItemPrivate
friend

Definition at line 114 of file qgraphicssceneindex_p.h.

◆ QGraphicsScene

friend class QGraphicsScene
friend

Definition at line 111 of file qgraphicssceneindex_p.h.

◆ QGraphicsSceneBspTreeIndex

friend class QGraphicsSceneBspTreeIndex
friend

Definition at line 115 of file qgraphicssceneindex_p.h.

◆ QGraphicsScenePrivate

friend class QGraphicsScenePrivate
friend

Definition at line 112 of file qgraphicssceneindex_p.h.


The documentation for this class was generated from the following files: