Qt 4.8
|
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items. More...
#include <qgraphicsscene.h>
Public Types | |
enum | ItemIndexMethod { BspTreeIndex, NoIndex = -1 } |
This enum describes the indexing algorithms QGraphicsScene provides for managing positional information about items on the scene. More... | |
enum | SceneLayer { ItemLayer = 0x1, BackgroundLayer = 0x2, ForegroundLayer = 0x4, AllLayers = 0xffff } |
This enum describes the rendering layers in a QGraphicsScene. More... | |
Public Slots | |
void | advance () |
This slot advances the scene by one step, by calling QGraphicsItem::advance() for all items on the scene. More... | |
void | clear () |
Removes and deletes all items from the scene, but otherwise leaves the state of the scene unchanged. More... | |
void | clearSelection () |
Clears the current selection. More... | |
void | invalidate (const QRectF &rect=QRectF(), SceneLayers layers=AllLayers) |
Invalidates and schedules a redraw of the layers in rect on the scene. More... | |
void | update (const QRectF &rect=QRectF()) |
Schedules a redraw of the area rect on the scene. More... | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Signals | |
void | changed (const QList< QRectF > ®ion) |
This signal is emitted by QGraphicsScene when control reaches the event loop, if the scene content changes. More... | |
void | sceneRectChanged (const QRectF &rect) |
This signal is emitted by QGraphicsScene whenever the scene rect changes. More... | |
void | selectionChanged () |
This signal is emitted by QGraphicsScene whenever the selection changes. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Public Functions | |
QGraphicsItem * | activePanel () const |
Returns the current active panel, or 0 if no panel is currently active. More... | |
QGraphicsWidget * | activeWindow () const |
Returns the current active window, or 0 if no window is currently active. More... | |
QGraphicsEllipseItem * | addEllipse (const QRectF &rect, const QPen &pen=QPen(), const QBrush &brush=QBrush()) |
Creates and adds an ellipse item to the scene, and returns the item pointer. More... | |
QGraphicsEllipseItem * | addEllipse (qreal x, qreal y, qreal w, qreal h, const QPen &pen=QPen(), const QBrush &brush=QBrush()) |
void | addItem (QGraphicsItem *item) |
Adds or moves the item and all its childen to this scene. More... | |
QGraphicsLineItem * | addLine (const QLineF &line, const QPen &pen=QPen()) |
Creates and adds a line item to the scene, and returns the item pointer. More... | |
QGraphicsLineItem * | addLine (qreal x1, qreal y1, qreal x2, qreal y2, const QPen &pen=QPen()) |
QGraphicsPathItem * | addPath (const QPainterPath &path, const QPen &pen=QPen(), const QBrush &brush=QBrush()) |
Creates and adds a path item to the scene, and returns the item pointer. More... | |
QGraphicsPixmapItem * | addPixmap (const QPixmap &pixmap) |
Creates and adds a pixmap item to the scene, and returns the item pointer. More... | |
QGraphicsPolygonItem * | addPolygon (const QPolygonF &polygon, const QPen &pen=QPen(), const QBrush &brush=QBrush()) |
Creates and adds a polygon item to the scene, and returns the item pointer. More... | |
QGraphicsRectItem * | addRect (const QRectF &rect, const QPen &pen=QPen(), const QBrush &brush=QBrush()) |
Creates and adds a rectangle item to the scene, and returns the item pointer. More... | |
QGraphicsRectItem * | addRect (qreal x, qreal y, qreal w, qreal h, const QPen &pen=QPen(), const QBrush &brush=QBrush()) |
QGraphicsSimpleTextItem * | addSimpleText (const QString &text, const QFont &font=QFont()) |
Creates and adds a QGraphicsSimpleTextItem to the scene, and returns the item pointer. More... | |
QGraphicsTextItem * | addText (const QString &text, const QFont &font=QFont()) |
Creates and adds a text item to the scene, and returns the item pointer. More... | |
QGraphicsProxyWidget * | addWidget (QWidget *widget, Qt::WindowFlags wFlags=0) |
Creates a new QGraphicsProxyWidget for widget, adds it to the scene, and returns a pointer to the proxy. More... | |
QBrush | backgroundBrush () const |
int | bspTreeDepth () const |
void | clearFocus () |
Clears focus from the scene. More... | |
QList< QGraphicsItem * > | collidingItems (const QGraphicsItem *item, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const |
Returns a list of all items that collide with item. More... | |
QGraphicsItemGroup * | createItemGroup (const QList< QGraphicsItem *> &items) |
Groups all items in items into a new QGraphicsItemGroup, and returns a pointer to the group. More... | |
void | destroyItemGroup (QGraphicsItemGroup *group) |
Reparents all items in group to group's parent item, then removes group from the scene, and finally deletes it. More... | |
QGraphicsItem * | focusItem () const |
When the scene is active, this functions returns the scene's current focus item, or 0 if no item currently has focus. More... | |
QFont | font () const |
QBrush | foregroundBrush () const |
bool | hasFocus () const |
Returns true if the scene has focus; otherwise returns false. More... | |
qreal | height () const |
This convenience function is equivalent to calling sceneRect() . More... | |
virtual QVariant | inputMethodQuery (Qt::InputMethodQuery query) const |
This method is used by input methods to query a set of properties of the scene to be able to support complex input method operations as support for surrounding text and reconversions. More... | |
void | invalidate (qreal x, qreal y, qreal w, qreal h, SceneLayers layers=AllLayers) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
bool | isActive () const |
Returns true if the scene is active (e. More... | |
bool | isSortCacheEnabled () const |
QGraphicsItem * | itemAt (const QPointF &pos) const |
Returns the topmost visible item at the specified position, or 0 if there are no items at this position. More... | |
QGraphicsItem * | itemAt (const QPointF &pos, const QTransform &deviceTransform) const |
Returns the topmost visible item at the specified position, or 0 if there are no items at this position. More... | |
QGraphicsItem * | itemAt (qreal x, qreal y) const |
Returns the topmost item at the position specified by (x, y), or 0 if there are no items at this position. More... | |
QGraphicsItem * | itemAt (qreal x, qreal y, const QTransform &deviceTransform) const |
Returns the topmost item at the position specified by (x, y), or 0 if there are no items at this position. More... | |
ItemIndexMethod | itemIndexMethod () const |
QList< QGraphicsItem * > | items () const |
Returns a list of all items in the scene in descending stacking order. More... | |
QList< QGraphicsItem * > | items (Qt::SortOrder order) const |
Returns an ordered list of all items on the scene. More... | |
QList< QGraphicsItem * > | items (const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const |
Returns all visible items that, depending on mode, are at the specified pos in a list sorted using order. More... | |
QList< QGraphicsItem * > | items (const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const |
Returns all visible items that, depending on mode, are either inside or intersect with the specified rect and return a list sorted using order. More... | |
QList< QGraphicsItem * > | items (const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const |
Returns all visible items that, depending on mode, are either inside or intersect with the specified polygon and return a list sorted using order. More... | |
QList< QGraphicsItem * > | items (const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const |
Returns all visible items that, depending on mode, are either inside or intersect with the specified path and return a list sorted using order. More... | |
QList< QGraphicsItem * > | items (const QPointF &pos) const |
Returns all visible items at position pos in the scene. More... | |
QList< QGraphicsItem * > | items (const QRectF &rect, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const |
Returns all visible items that, depending on mode, are either inside or intersect with the specified rectangle. More... | |
QList< QGraphicsItem * > | items (const QPolygonF &polygon, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
QList< QGraphicsItem * > | items (const QPainterPath &path, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
QList< QGraphicsItem * > | items (qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode=Qt::IntersectsItemShape) const |
QList< QGraphicsItem * > | items (qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform=QTransform()) const |
Returns all visible items that, depending on mode, are either inside or intersect with the rectangle defined by x, y,. More... | |
QRectF | itemsBoundingRect () const |
Calculates and returns the bounding rect of all items on the scene. More... | |
QGraphicsItem * | mouseGrabberItem () const |
Returns the current mouse grabber item, or 0 if no item is currently grabbing the mouse. More... | |
QPalette | palette () const |
QGraphicsScene (QObject *parent=0) | |
Constructs a QGraphicsScene object. More... | |
QGraphicsScene (const QRectF &sceneRect, QObject *parent=0) | |
Constructs a QGraphicsScene object, using sceneRect for its scene rectangle. More... | |
QGraphicsScene (qreal x, qreal y, qreal width, qreal height, QObject *parent=0) | |
Constructs a QGraphicsScene object, using the rectangle specified by (x, y), and the given width and height for its scene rectangle. More... | |
void | removeItem (QGraphicsItem *item) |
Removes the item item and all its children from the scene. More... | |
void | render (QPainter *painter, const QRectF &target=QRectF(), const QRectF &source=QRectF(), Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio) |
Renders the source rect from scene into target, using painter. More... | |
QRectF | sceneRect () const |
QList< QGraphicsItem * > | selectedItems () const |
Returns a list of all currently selected items. More... | |
QPainterPath | selectionArea () const |
Returns the selection area that was previously set with setSelectionArea(), or an empty QPainterPath if no selection area has been set. More... | |
bool | sendEvent (QGraphicsItem *item, QEvent *event) |
Sends event event to item item through possible event filters. More... | |
void | setActivePanel (QGraphicsItem *item) |
Activates item, which must be an item in this scene. More... | |
void | setActiveWindow (QGraphicsWidget *widget) |
Activates widget, which must be a widget in this scene. More... | |
void | setBackgroundBrush (const QBrush &brush) |
void | setBspTreeDepth (int depth) |
void | setFocus (Qt::FocusReason focusReason=Qt::OtherFocusReason) |
Sets focus on the scene by sending a QFocusEvent to the scene, passing focusReason as the reason. More... | |
void | setFocusItem (QGraphicsItem *item, Qt::FocusReason focusReason=Qt::OtherFocusReason) |
Sets the scene's focus item to item, with the focus reason focusReason, after removing focus from any previous item that may have had focus. More... | |
void | setFont (const QFont &font) |
void | setForegroundBrush (const QBrush &brush) |
void | setItemIndexMethod (ItemIndexMethod method) |
void | setPalette (const QPalette &palette) |
void | setSceneRect (const QRectF &rect) |
void | setSceneRect (qreal x, qreal y, qreal w, qreal h) |
void | setSelectionArea (const QPainterPath &path) |
Sets the selection area to path. More... | |
void | setSelectionArea (const QPainterPath &path, const QTransform &deviceTransform) |
Sets the selection area to path. More... | |
void | setSelectionArea (const QPainterPath &path, Qt::ItemSelectionMode mode) |
Sets the selection area to path using mode to determine if items are included in the selection area. More... | |
void | setSelectionArea (const QPainterPath &path, Qt::ItemSelectionMode mode, const QTransform &deviceTransform) |
Sets the selection area to path using mode to determine if items are included in the selection area. More... | |
void | setSortCacheEnabled (bool enabled) |
void | setStickyFocus (bool enabled) |
void | setStyle (QStyle *style) |
Sets or replaces the style of the scene to style, and reparents the style to this scene. More... | |
bool | stickyFocus () const |
QStyle * | style () const |
Returns the scene's style, or the same as QApplication::style() if the scene has not been explicitly assigned a style. More... | |
void | update (qreal x, qreal y, qreal w, qreal h) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
QList< QGraphicsView * > | views () const |
Returns a list of all the views that display this scene. More... | |
qreal | width () const |
This convenience function is equivalent to calling sceneRect(). More... | |
virtual | ~QGraphicsScene () |
Removes and deletes all items from the scene object before destroying the scene object. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Protected Slots | |
bool | focusNextPrevChild (bool next) |
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it cannot. More... | |
Protected Functions | |
virtual void | contextMenuEvent (QGraphicsSceneContextMenuEvent *event) |
This event handler, for event contextMenuEvent, can be reimplemented in a subclass to receive context menu events. More... | |
virtual void | dragEnterEvent (QGraphicsSceneDragDropEvent *event) |
This event handler, for event event, can be reimplemented in a subclass to receive drag enter events for the scene. More... | |
virtual void | dragLeaveEvent (QGraphicsSceneDragDropEvent *event) |
This event handler, for event event, can be reimplemented in a subclass to receive drag leave events for the scene. More... | |
virtual void | dragMoveEvent (QGraphicsSceneDragDropEvent *event) |
This event handler, for event event, can be reimplemented in a subclass to receive drag move events for the scene. More... | |
virtual void | drawBackground (QPainter *painter, const QRectF &rect) |
Draws the background of the scene using painter, before any items and the foreground are drawn. More... | |
virtual void | drawForeground (QPainter *painter, const QRectF &rect) |
Draws the foreground of the scene using painter, after the background and all items have been drawn. More... | |
virtual void | 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. More... | |
virtual void | dropEvent (QGraphicsSceneDragDropEvent *event) |
This event handler, for event event, can be reimplemented in a subclass to receive drop events for the scene. More... | |
bool | event (QEvent *event) |
Processes the event event, and dispatches it to the respective event handlers. More... | |
bool | eventFilter (QObject *watched, QEvent *event) |
QGraphicsScene filters QApplication's events to detect palette and font changes. More... | |
virtual void | focusInEvent (QFocusEvent *event) |
This event handler, for event focusEvent, can be reimplemented in a subclass to receive focus in events. More... | |
virtual void | focusOutEvent (QFocusEvent *event) |
This event handler, for event focusEvent, can be reimplemented in a subclass to receive focus out events. More... | |
virtual void | helpEvent (QGraphicsSceneHelpEvent *event) |
This event handler, for event helpEvent, can be reimplemented in a subclass to receive help events. More... | |
virtual void | inputMethodEvent (QInputMethodEvent *event) |
This event handler, for event event, can be reimplemented in a subclass to receive input method events for the scene. More... | |
virtual void | keyPressEvent (QKeyEvent *event) |
This event handler, for event keyEvent, can be reimplemented in a subclass to receive keypress events. More... | |
virtual void | keyReleaseEvent (QKeyEvent *event) |
This event handler, for event keyEvent, can be reimplemented in a subclass to receive key release events. More... | |
virtual void | mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) |
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse doubleclick events for the scene. More... | |
virtual void | mouseMoveEvent (QGraphicsSceneMouseEvent *event) |
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse move events for the scene. More... | |
virtual void | mousePressEvent (QGraphicsSceneMouseEvent *event) |
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse press events for the scene. More... | |
virtual void | mouseReleaseEvent (QGraphicsSceneMouseEvent *event) |
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse release events for the scene. More... | |
virtual void | wheelEvent (QGraphicsSceneWheelEvent *event) |
This event handler, for event wheelEvent, can be reimplemented in a subclass to receive mouse wheel events for the scene. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Properties | |
QBrush | backgroundBrush |
the background brush of the scene. More... | |
int | bspTreeDepth |
the depth of QGraphicsScene's BSP index tree More... | |
QFont | font |
the scene's default font More... | |
QBrush | foregroundBrush |
the foreground brush of the scene. More... | |
ItemIndexMethod | itemIndexMethod |
the item indexing method. More... | |
QPalette | palette |
the scene's default palette More... | |
QRectF | sceneRect |
the scene rectangle; the bounding rectangle of the scene More... | |
bool | sortCacheEnabled |
whether sort caching is enabled More... | |
bool | stickyFocus |
whether clicking into the scene background will clear focus More... | |
Additional Inherited Members | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
The class serves as a container for QGraphicsItems. It is used together with QGraphicsView for visualizing graphical items, such as lines, rectangles, text, or even custom items, on a 2D surface. QGraphicsScene is part of the Graphics View Framework.
QGraphicsScene also provides functionality that lets you efficiently determine both the location of items, and for determining what items are visible within an arbitrary area on the scene. With the QGraphicsView widget, you can either visualize the whole scene, or zoom in and view only parts of the scene.
Example:
Note that QGraphicsScene has no visual appearance of its own; it only manages the items. You need to create a QGraphicsView widget to visualize the scene.
To add items to a scene, you start off by constructing a QGraphicsScene object. Then, you have two options: either add your existing QGraphicsItem objects by calling addItem(), or you can call one of the convenience functions addEllipse(), addLine(), addPath(), addPixmap(), addPolygon(), addRect(), or addText(), which all return a pointer to the newly added item. The dimensions of the items added with these functions are relative to the item's coordinate system, and the items position is initialized to (0, 0) in the scene.
You can then visualize the scene using QGraphicsView. When the scene changes, (e.g., when an item moves or is transformed) QGraphicsScene emits the changed() signal. To remove an item, call removeItem().
QGraphicsScene uses an indexing algorithm to manage the location of items efficiently. By default, a BSP (Binary Space Partitioning) tree is used; an algorithm suitable for large scenes where most items remain static (i.e., do not move around). You can choose to disable this index by calling setItemIndexMethod(). For more information about the available indexing algorithms, see the itemIndexMethod property.
The scene's bounding rect is set by calling setSceneRect(). Items can be placed at any position on the scene, and the size of the scene is by default unlimited. The scene rect is used only for internal bookkeeping, maintaining the scene's item index. If the scene rect is unset, QGraphicsScene will use the bounding area of all items, as returned by itemsBoundingRect(), as the scene rect. However, itemsBoundingRect() is a relatively time consuming function, as it operates by collecting positional information for every item on the scene. Because of this, you should always set the scene rect when operating on large scenes.
One of QGraphicsScene's greatest strengths is its ability to efficiently determine the location of items. Even with millions of items on the scene, the items() functions can determine the location of an item within few milliseconds. There are several overloads to items(): one that finds items at a certain position, one that finds items inside or intersecting with a polygon or a rectangle, and more. The list of returned items is sorted by stacking order, with the topmost item being the first item in the list. For convenience, there is also an itemAt() function that returns the topmost item at a given position.
QGraphicsScene maintains selection information for the scene. To select items, call setSelectionArea(), and to clear the current selection, call clearSelection(). Call selectedItems() to get the list of all selected items.
Another responsibility that QGraphicsScene has, is to propagate events from QGraphicsView. To send an event to a scene, you construct an event that inherits QEvent, and then send it using, for example, QApplication::sendEvent(). event() is responsible for dispatching the event to the individual items. Some common events are handled by convenience event handlers. For example, key press events are handled by keyPressEvent(), and mouse press events are handled by mousePressEvent().
Key events are delivered to the {focus item}. To set the focus item, you can either call setFocusItem(), passing an item that accepts focus, or the item itself can call QGraphicsItem::setFocus(). Call focusItem() to get the current focus item. For compatibility with widgets, the scene also maintains its own focus information. By default, the scene does not have focus, and all key events are discarded. If setFocus() is called, or if an item on the scene gains focus, the scene automatically gains focus. If the scene has focus, hasFocus() will return true, and key events will be forwarded to the focus item, if any. If the scene loses focus, (i.e., someone calls clearFocus()) while an item has focus, the scene will maintain its item focus information, and once the scene regains focus, it will make sure the last focus item regains focus.
For mouse-over effects, QGraphicsScene dispatches {hover events}. If an item accepts hover events (see QGraphicsItem::acceptHoverEvents()), it will receive a QEvent::GraphicsSceneHoverEnter event when the mouse enters its area. As the mouse continues moving inside the item's area, QGraphicsScene will send it QEvent::GraphicsSceneHoverMove events. When the mouse leaves the item's area, the item will receive a QEvent::GraphicsSceneHoverLeave event.
All mouse events are delivered to the current {mouse grabber} item. An item becomes the scene's mouse grabber if it accepts mouse events (see QGraphicsItem::acceptedMouseButtons()) and it receives a mouse press. It stays the mouse grabber until it receives a mouse release when no other mouse buttons are pressed. You can call mouseGrabberItem() to determine what item is currently grabbing the mouse.
Definition at line 101 of file qgraphicsscene.h.
This enum describes the indexing algorithms QGraphicsScene provides for managing positional information about items on the scene.
Enumerator | |
---|---|
BspTreeIndex | |
NoIndex |
Definition at line 115 of file qgraphicsscene.h.
This enum describes the rendering layers in a QGraphicsScene.
When QGraphicsScene draws the scene contents, it renders each of these layers separately, in order.
Each layer represents a flag that can be OR'ed together when calling functions such as invalidate() or QGraphicsView::invalidateScene().
Enumerator | |
---|---|
ItemLayer | |
BackgroundLayer | |
ForegroundLayer | |
AllLayers |
Definition at line 120 of file qgraphicsscene.h.
QGraphicsScene::QGraphicsScene | ( | QObject * | parent = 0 | ) |
Constructs a QGraphicsScene object.
The parent parameter is passed to QObject's constructor.
Definition at line 1638 of file qgraphicsscene.cpp.
Constructs a QGraphicsScene object, using sceneRect for its scene rectangle.
The parent parameter is passed to QObject's constructor.
Definition at line 1651 of file qgraphicsscene.cpp.
QGraphicsScene::QGraphicsScene | ( | qreal | x, |
qreal | y, | ||
qreal | width, | ||
qreal | height, | ||
QObject * | parent = 0 |
||
) |
Constructs a QGraphicsScene object, using the rectangle specified by (x, y), and the given width and height for its scene rectangle.
The parent parameter is passed to QObject's constructor.
Definition at line 1666 of file qgraphicsscene.cpp.
|
virtual |
Removes and deletes all items from the scene object before destroying the scene object.
The scene object is removed from the application's global scene list, and it is removed from all associated views.
Definition at line 1679 of file qgraphicsscene.cpp.
QGraphicsItem * QGraphicsScene::activePanel | ( | ) | const |
Returns the current active panel, or 0 if no panel is currently active.
Definition at line 5818 of file qgraphicsscene.cpp.
Referenced by QGraphicsItem::hasFocus(), and QGraphicsItem::isActive().
QGraphicsWidget * QGraphicsScene::activeWindow | ( | ) | const |
Returns the current active window, or 0 if no window is currently active.
Definition at line 5855 of file qgraphicsscene.cpp.
Referenced by QShortcutMap::correctGraphicsWidgetContext().
QGraphicsEllipseItem * QGraphicsScene::addEllipse | ( | const QRectF & | rect, |
const QPen & | pen = QPen() , |
||
const QBrush & | brush = QBrush() |
||
) |
Creates and adds an ellipse item to the scene, and returns the item pointer.
The geometry of the ellipse is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
Definition at line 2833 of file qgraphicsscene.cpp.
|
inline |
This convenience function is equivalent to calling addEllipse(QRectF(x, y, w, h), pen, brush).
Definition at line 203 of file qgraphicsscene.h.
void QGraphicsScene::addItem | ( | QGraphicsItem * | item | ) |
Adds or moves the item and all its childen to this scene.
This scene takes ownership of the item.
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
If the item is already in a different scene, it will first be removed from its old scene, and then added to this scene as a top-level.
QGraphicsScene will send ItemSceneChange notifications to item while it is added to the scene. If item does not currently belong to a scene, only one notification is sent. If it does belong to scene already (i.e., it is moved to this scene), QGraphicsScene will send an addition notification as the item is removed from its previous scene.
If the item is a panel, the scene is active, and there is no active panel in the scene, then the item will be activated.
Definition at line 2650 of file qgraphicsscene.cpp.
Referenced by addEllipse(), addItem(), addLine(), addPath(), addPixmap(), addPolygon(), addRect(), addSimpleText(), addText(), QGraphicsItem::addToIndex(), addWidget(), createItemGroup(), QmlJSDebugger::LiveLayerItem::LiveLayerItem(), QGraphicsItem::QGraphicsItem(), removeItem(), and QDeclarativeView::setRootObject().
QGraphicsLineItem * QGraphicsScene::addLine | ( | const QLineF & | line, |
const QPen & | pen = QPen() |
||
) |
Creates and adds a line item to the scene, and returns the item pointer.
The geometry of the line is defined by line, and its pen is initialized to pen.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
Definition at line 2865 of file qgraphicsscene.cpp.
|
inline |
This convenience function is equivalent to calling addLine(QLineF(x1, y1, x2, y2), pen).
Definition at line 205 of file qgraphicsscene.h.
QGraphicsPathItem * QGraphicsScene::addPath | ( | const QPainterPath & | path, |
const QPen & | pen = QPen() , |
||
const QBrush & | brush = QBrush() |
||
) |
Creates and adds a path item to the scene, and returns the item pointer.
The geometry of the path is defined by path, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
Definition at line 2896 of file qgraphicsscene.cpp.
QGraphicsPixmapItem * QGraphicsScene::addPixmap | ( | const QPixmap & | pixmap | ) |
Creates and adds a pixmap item to the scene, and returns the item pointer.
The pixmap is defined by pixmap.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
Definition at line 2919 of file qgraphicsscene.cpp.
QGraphicsPolygonItem * QGraphicsScene::addPolygon | ( | const QPolygonF & | polygon, |
const QPen & | pen = QPen() , |
||
const QBrush & | brush = QBrush() |
||
) |
Creates and adds a polygon item to the scene, and returns the item pointer.
The polygon is defined by polygon, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
Definition at line 2941 of file qgraphicsscene.cpp.
QGraphicsRectItem * QGraphicsScene::addRect | ( | const QRectF & | rect, |
const QPen & | pen = QPen() , |
||
const QBrush & | brush = QBrush() |
||
) |
Creates and adds a rectangle item to the scene, and returns the item pointer.
The geometry of the rectangle is defined by rect, and its pen and brush are initialized to pen and brush.
Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0). For example, if a QRect(50, 50, 100, 100) is added, its top-left corner will be at (50, 50) relative to the origin in the items coordinate system.
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
Definition at line 2968 of file qgraphicsscene.cpp.
|
inline |
This convenience function is equivalent to calling addRect(QRectF(x, y, w, h), pen, brush).
Definition at line 207 of file qgraphicsscene.h.
QGraphicsSimpleTextItem * QGraphicsScene::addSimpleText | ( | const QString & | text, |
const QFont & | font = QFont() |
||
) |
Creates and adds a QGraphicsSimpleTextItem to the scene, and returns the item pointer.
The text string is initialized to text, and its font is initialized to font.
The item's position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
Definition at line 3021 of file qgraphicsscene.cpp.
QGraphicsTextItem * QGraphicsScene::addText | ( | const QString & | text, |
const QFont & | font = QFont() |
||
) |
Creates and adds a text item to the scene, and returns the item pointer.
The text string is initialized to text, and its font is initialized to font.
The item's position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
Definition at line 2999 of file qgraphicsscene.cpp.
QGraphicsProxyWidget * QGraphicsScene::addWidget | ( | QWidget * | widget, |
Qt::WindowFlags | wFlags = 0 |
||
) |
Creates a new QGraphicsProxyWidget for widget, adds it to the scene, and returns a pointer to the proxy.
wFlags set the default window flags for the embedding proxy widget.
The item's position is initialized to (0, 0).
If the item is visible (i.e., QGraphicsItem::isVisible() returns true), QGraphicsScene will emit changed() once control goes back to the event loop.
Note that widgets with the Qt::WA_PaintOnScreen widget attribute set and widgets that wrap an external application or controller are not supported. Examples are QGLWidget and QAxWidget.
Definition at line 3047 of file qgraphicsscene.cpp.
|
slot |
This slot advances the scene by one step, by calling QGraphicsItem::advance() for all items on the scene.
This is done in two phases: in the first phase, all items are notified that the scene is about to change, and in the second phase all items are notified that they can move. In the first phase, QGraphicsItem::advance() is called passing a value of 0 as an argument, and 1 is passed in the second phase.
Definition at line 3461 of file qgraphicsscene.cpp.
QBrush QGraphicsScene::backgroundBrush | ( | ) | const |
Referenced by drawBackground(), and mouseGrabberItem().
int QGraphicsScene::bspTreeDepth | ( | ) | const |
Referenced by setItemIndexMethod().
This signal is emitted by QGraphicsScene when control reaches the event loop, if the scene content changes.
The region parameter contains a list of scene rectangles that indicate the area that has been changed.
Referenced by clearSelection(), and setSelectionArea().
|
slot |
Removes and deletes all items from the scene, but otherwise leaves the state of the scene unchanged.
Definition at line 2538 of file qgraphicsscene.cpp.
Referenced by QGraphicsItem::mouseReleaseEvent(), and ~QGraphicsScene().
void QGraphicsScene::clearFocus | ( | ) |
Clears focus from the scene.
If any item has focus when this function is called, it will lose focus, and regain focus again once the scene regains focus.
A scene that does not have focus ignores key events.
Definition at line 3178 of file qgraphicsscene.cpp.
|
slot |
Clears the current selection.
Definition at line 2508 of file qgraphicsscene.cpp.
Referenced by QGraphicsItem::mousePressEvent(), and QGraphicsItem::mouseReleaseEvent().
QList< QGraphicsItem * > QGraphicsScene::collidingItems | ( | const QGraphicsItem * | item, |
Qt::ItemSelectionMode | mode = Qt::IntersectsItemShape |
||
) | const |
Returns a list of all items that collide with item.
Collisions are determined by calling QGraphicsItem::collidesWithItem(); the collision detection is determined by mode. By default, all items whose shape intersects item or is contained inside item's shape are returned.
The items are returned in descending stacking order (i.e., the first item in the list is the uppermost item, and the last item is the lowermost item).
Definition at line 2255 of file qgraphicsscene.cpp.
Referenced by QGraphicsItem::collidingItems().
|
protectedvirtual |
This event handler, for event contextMenuEvent, can be reimplemented in a subclass to receive context menu events.
The default implementation forwards the event to the topmost item that accepts context menu events at the position of the event. If no items accept context menu events at this position, the event is ignored.
Definition at line 3722 of file qgraphicsscene.cpp.
Referenced by event().
QGraphicsItemGroup * QGraphicsScene::createItemGroup | ( | const QList< QGraphicsItem *> & | items | ) |
Groups all items in items into a new QGraphicsItemGroup, and returns a pointer to the group.
The group is created with the common ancestor of items as its parent, and with position (0, 0). The items are all reparented to the group, and their positions and transformations are mapped to the group. If items is empty, this function will return an empty top-level QGraphicsItemGroup.
QGraphicsScene has ownership of the group item; you do not need to delete it. To dismantle (ungroup) a group, call destroyItemGroup().
Definition at line 2567 of file qgraphicsscene.cpp.
void QGraphicsScene::destroyItemGroup | ( | QGraphicsItemGroup * | group | ) |
Reparents all items in group to group's parent item, then removes group from the scene, and finally deletes it.
The items' positions and transformations are mapped from the group to the group's parent.
Definition at line 2617 of file qgraphicsscene.cpp.
|
protectedvirtual |
This event handler, for event event, can be reimplemented in a subclass to receive drag enter events for the scene.
The default implementation accepts the event and prepares the scene to accept drag move events.
Definition at line 3754 of file qgraphicsscene.cpp.
Referenced by event().
|
protectedvirtual |
This event handler, for event event, can be reimplemented in a subclass to receive drag leave events for the scene.
Definition at line 3852 of file qgraphicsscene.cpp.
Referenced by event().
|
protectedvirtual |
This event handler, for event event, can be reimplemented in a subclass to receive drag move events for the scene.
Definition at line 3769 of file qgraphicsscene.cpp.
Referenced by event().
Draws the background of the scene using painter, before any items and the foreground are drawn.
Reimplement this function to provide a custom background for the scene.
All painting is done in scene coordinates. The rect parameter is the exposed rectangle.
If all you want is to define a color, texture, or gradient for the background, you can call setBackgroundBrush() instead.
Definition at line 4381 of file qgraphicsscene.cpp.
Referenced by render().
Draws the foreground of the scene using painter, after the background and all items have been drawn.
Reimplement this function to provide a custom foreground for the scene.
All painting is done in scene coordinates. The rect parameter is the exposed rectangle.
If all you want is to define a color, texture or gradient for the foreground, you can call setForegroundBrush() instead.
Definition at line 4408 of file qgraphicsscene.cpp.
Referenced by render().
|
protectedvirtual |
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:
Since Qt 4.6, this function is not called anymore unless the QGraphicsView::IndirectPainting flag is given as an Optimization flag.
Definition at line 5483 of file qgraphicsscene.cpp.
Referenced by render().
|
protectedvirtual |
This event handler, for event event, can be reimplemented in a subclass to receive drop events for the scene.
Definition at line 3869 of file qgraphicsscene.cpp.
Referenced by event().
|
protectedvirtual |
Processes the event event, and dispatches it to the respective event handlers.
In addition to calling the convenience event handlers, this function is responsible for converting mouse move events to hover events for when there is no mouse grabber item. Hover events are delivered directly to items; there is no convenience function for them.
Unlike QWidget, QGraphicsScene does not have the convenience functions QWidget::enterEvent() and QWidget::leaveEvent(). Use this function to obtain those events instead.
Reimplemented from QObject.
Definition at line 3487 of file qgraphicsscene.cpp.
Referenced by setFocus(), and setStyle().
QGraphicsScene filters QApplication's events to detect palette and font changes.
Reimplemented Function
Reimplemented from QObject.
Definition at line 3695 of file qgraphicsscene.cpp.
|
protectedvirtual |
This event handler, for event focusEvent, can be reimplemented in a subclass to receive focus in events.
The default implementation sets focus on the scene, and then on the last focus item.
Definition at line 3889 of file qgraphicsscene.cpp.
Referenced by event().
QGraphicsItem * QGraphicsScene::focusItem | ( | ) | const |
When the scene is active, this functions returns the scene's current focus item, or 0 if no item currently has focus.
When the scene is inactive, this functions returns the item that will gain input focus when the scene becomes active.
The focus item receives keyboard input when the scene receives a key event.
Definition at line 3106 of file qgraphicsscene.cpp.
Referenced by QShortcutMap::correctGraphicsWidgetContext(), QMotifStyle::event(), QMacStyle::event(), event(), QUIKitSoftwareInputHandler::eventFilter(), focusNextPrevChild(), QDeclarativeItem::hasActiveFocus(), QGraphicsItem::hasFocus(), keyPressEvent(), keyReleaseEvent(), QGraphicsItemPrivate::setEnabledHelper(), QGraphicsItemPrivate::setFocusHelper(), QGraphicsItemPrivate::setVisibleHelper(), QGraphicsViewPrivate::updateInputMethodSensitivity(), and wheelEvent().
|
protectedslot |
Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns true if it can find a new widget, or false if it cannot.
If next is true, this function searches forward; if next is false, it searches backward.
You can reimplement this function in a subclass of QGraphicsScene to provide fine-grained control over how tab focus passes inside your scene. The default implementation is based on the tab focus chain defined by QGraphicsWidget::setTabOrder().
Definition at line 5546 of file qgraphicsscene.cpp.
Referenced by event(), focusInEvent(), and QGraphicsItem::sceneEvent().
|
protectedvirtual |
This event handler, for event focusEvent, can be reimplemented in a subclass to receive focus out events.
The default implementation removes focus from any focus item, then removes focus from the scene.
Definition at line 3921 of file qgraphicsscene.cpp.
Referenced by event().
QFont QGraphicsScene::font | ( | ) | const |
Referenced by setStyle().
QBrush QGraphicsScene::foregroundBrush | ( | ) | const |
Referenced by drawForeground(), and setBackgroundBrush().
bool QGraphicsScene::hasFocus | ( | ) | const |
Returns true if the scene has focus; otherwise returns false.
If the scene has focus, it will will forward key events from QKeyEvent to any item that has focus.
Definition at line 3144 of file qgraphicsscene.cpp.
Referenced by QDeclarativeTextEditPrivate::focusChanged(), and QDeclarativeTextInputPrivate::focusChanged().
|
inline |
This convenience function is equivalent to calling sceneRect()
.
\sa width()
Definition at line 135 of file qgraphicsscene.h.
|
protectedvirtual |
This event handler, for event helpEvent, can be reimplemented in a subclass to receive help events.
The events are of type QEvent::ToolTip, which are created when a tooltip is requested.
The default implementation shows the tooltip of the topmost item, i.e., the item with the highest z-value, at the mouse cursor position. If no item has a tooltip set, this function does nothing.
Definition at line 3946 of file qgraphicsscene.cpp.
Referenced by event().
|
protectedvirtual |
This event handler, for event event, can be reimplemented in a subclass to receive input method events for the scene.
The default implementation forwards the event to the focusItem(). If no item currently has focus or the current focus item does not accept input methods, this function does nothing.
Definition at line 4361 of file qgraphicsscene.cpp.
Referenced by event().
|
virtual |
This method is used by input methods to query a set of properties of the scene to be able to support complex input method operations as support for surrounding text and reconversions.
The query parameter specifies which property is queried.
Definition at line 3329 of file qgraphicsscene.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This convenience function is equivalent to calling invalidate(QRectF(x, y, w, h), layers);
Definition at line 234 of file qgraphicsscene.h.
|
slot |
Invalidates and schedules a redraw of the layers in rect on the scene.
Any cached content in layers is unconditionally invalidated and redrawn.
You can use this function overload to notify QGraphicsScene of changes to the background or the foreground of the scene. This function is commonly used for scenes with tile-based backgrounds to notify changes when QGraphicsView has enabled CacheBackground.
Example:
Note that QGraphicsView currently supports background caching only (see QGraphicsView::CacheBackground). This function is equivalent to calling update() if any layer but BackgroundLayer is passed.
Definition at line 3424 of file qgraphicsscene.cpp.
bool QGraphicsScene::isActive | ( | ) | const |
Returns true if the scene is active (e.
g., it's viewed by at least one QGraphicsView that is active); otherwise returns false.
Definition at line 5803 of file qgraphicsscene.cpp.
Referenced by addItem(), focusItem(), QGraphicsItem::hasFocus(), QGraphicsItem::isActive(), setFocus(), QGraphicsItemPrivate::setFocusHelper(), and QGraphicsItemPrivate::setSubFocus().
bool QGraphicsScene::isSortCacheEnabled | ( | ) | const |
Definition at line 1964 of file qgraphicsscene.cpp.
QGraphicsItem * QGraphicsScene::itemAt | ( | const QPointF & | position | ) | const |
Returns the topmost visible item at the specified position, or 0 if there are no items at this position.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.
Definition at line 2289 of file qgraphicsscene.cpp.
QGraphicsItem * QGraphicsScene::itemAt | ( | const QPointF & | position, |
const QTransform & | deviceTransform | ||
) | const |
Returns the topmost visible item at the specified position, or 0 if there are no items at this position.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
Definition at line 2309 of file qgraphicsscene.cpp.
Returns the topmost item at the position specified by (x, y), or 0 if there are no items at this position.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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.
Definition at line 178 of file qgraphicsscene.h.
|
inline |
Returns the topmost item at the position specified by (x, y), or 0 if there are no items at this position.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
This convenience function is equivalent to calling {itemAt(QPointF(x, y), deviceTransform)}
.
Definition at line 180 of file qgraphicsscene.h.
ItemIndexMethod QGraphicsScene::itemIndexMethod | ( | ) | const |
Referenced by render().
QList< QGraphicsItem * > QGraphicsScene::items | ( | ) | const |
Returns a list of all items in the scene in descending stacking order.
Definition at line 1998 of file qgraphicsscene.cpp.
Referenced by advance(), QGraphicsScenePrivate::cancelGesturesForChildren(), QGraphicsScenePrivate::enterModal(), event(), QGraphicsViewPrivate::findItems(), QGraphicsScenePrivate::gestureTargetsAtHotSpots(), itemAt(), itemsBoundingRect(), QGraphicsScenePrivate::leaveModal(), render(), setActiveWindow(), setSelectionArea(), and setStyle().
QList< QGraphicsItem * > QGraphicsScene::items | ( | Qt::SortOrder | order | ) | const |
Returns an ordered list of all items on the scene.
order decides the stacking order.
Definition at line 2010 of file qgraphicsscene.cpp.
QList< QGraphicsItem * > QGraphicsScene::items | ( | const QPointF & | pos, |
Qt::ItemSelectionMode | mode, | ||
Qt::SortOrder | order, | ||
const QTransform & | deviceTransform = QTransform() |
||
) | const |
Returns all visible items that, depending on mode, are at the specified pos in 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 that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
Definition at line 2155 of file qgraphicsscene.cpp.
QList< QGraphicsItem * > QGraphicsScene::items | ( | const QRectF & | rect, |
Qt::ItemSelectionMode | mode, | ||
Qt::SortOrder | order, | ||
const QTransform & | deviceTransform = QTransform() |
||
) | const |
Returns all visible items that, depending on mode, are either inside or intersect with the specified rect and return a list sorted using order.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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 that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
Definition at line 2182 of file qgraphicsscene.cpp.
QList< QGraphicsItem * > QGraphicsScene::items | ( | const QPolygonF & | polygon, |
Qt::ItemSelectionMode | mode, | ||
Qt::SortOrder | order, | ||
const QTransform & | deviceTransform = QTransform() |
||
) | const |
Returns all visible items that, depending on mode, are either inside or intersect with the specified polygon and return a list sorted using order.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by polygon are returned.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
Definition at line 2209 of file qgraphicsscene.cpp.
QList< QGraphicsItem * > QGraphicsScene::items | ( | const QPainterPath & | path, |
Qt::ItemSelectionMode | mode, | ||
Qt::SortOrder | order, | ||
const QTransform & | deviceTransform = QTransform() |
||
) | const |
Returns all visible items that, depending on mode, are either inside or intersect with the specified path and return a list sorted using order.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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 that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
Definition at line 2236 of file qgraphicsscene.cpp.
QList< QGraphicsItem * > QGraphicsScene::items | ( | const QPointF & | pos | ) | const |
Returns all visible items at position pos in the scene.
The items are listed in descending stacking order (i.e., the first item in the list is the top-most item, and the last item is the bottom-most item).
This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.
Definition at line 2032 of file qgraphicsscene.cpp.
QList< QGraphicsItem * > QGraphicsScene::items | ( | const QRectF & | rectangle, |
Qt::ItemSelectionMode | mode = Qt::IntersectsItemShape |
||
) | const |
Returns all visible items that, depending on mode, are either inside or intersect with the specified rectangle.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by rectangle are returned.
This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.
Definition at line 2057 of file qgraphicsscene.cpp.
QList< QGraphicsItem * > QGraphicsScene::items | ( | const QPolygonF & | polygon, |
Qt::ItemSelectionMode | mode = Qt::IntersectsItemShape |
||
) | const |
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 polygon polygon.
The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by polygon are returned.
This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.
Definition at line 2108 of file qgraphicsscene.cpp.
QList< QGraphicsItem * > QGraphicsScene::items | ( | const QPainterPath & | path, |
Qt::ItemSelectionMode | mode = Qt::IntersectsItemShape |
||
) | const |
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 path, are either inside or intersect with the path path.
The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by path are returned.
This function is deprecated and returns incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.
Definition at line 2131 of file qgraphicsscene.cpp.
|
inline |
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.
Definition at line 173 of file qgraphicsscene.h.
|
inline |
Returns all visible items that, depending on mode, are either inside or intersect with the rectangle defined by x, y,.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
w and h, in a list sorted using order.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
Definition at line 175 of file qgraphicsscene.h.
QRectF QGraphicsScene::itemsBoundingRect | ( | ) | const |
Calculates and returns the bounding rect of all items on the scene.
This function works by iterating over all items, and because if this, it can be slow for large scenes.
Definition at line 1984 of file qgraphicsscene.cpp.
Referenced by ~QGraphicsScene().
|
protectedvirtual |
This event handler, for event keyEvent, can be reimplemented in a subclass to receive keypress events.
The default implementation forwards the event to current focus item.
Reimplemented in QDeclarativeScene.
Definition at line 4112 of file qgraphicsscene.cpp.
Referenced by event(), and QDeclarativeScene::keyPressEvent().
|
protectedvirtual |
This event handler, for event keyEvent, can be reimplemented in a subclass to receive key release events.
The default implementation forwards the event to current focus item.
Reimplemented in QDeclarativeScene.
Definition at line 4144 of file qgraphicsscene.cpp.
Referenced by event(), and QDeclarativeScene::keyReleaseEvent().
|
protectedvirtual |
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse doubleclick events for the scene.
If someone doubleclicks on the scene, the scene will first receive a mouse press event, followed by a release event (i.e., a click), then a doubleclick event, and finally a release event. If the doubleclick event is delivered to a different item than the one that received the first press and release, it will be delivered as a press event. However, tripleclick events are not delivered as doubleclick events in this case.
The default implementation is similar to mousePressEvent().
Definition at line 4287 of file qgraphicsscene.cpp.
Referenced by event().
QGraphicsItem * QGraphicsScene::mouseGrabberItem | ( | ) | const |
Returns the current mouse grabber item, or 0 if no item is currently grabbing the mouse.
The mouse grabber item is the item that receives all mouse events sent to the scene.
An item becomes a mouse grabber when it receives and accepts a mouse press event, and it stays the mouse grabber until either of the following events occur:
{item->setVisible(false)}
), or if it becomes disabled (i.e., someone calls {item->setEnabled(false)}
), it loses the mouse grab. If the item loses its mouse grab, the scene will ignore all mouse events until a new item grabs the mouse (i.e., until a new item receives a mouse press event).
Definition at line 3242 of file qgraphicsscene.cpp.
Referenced by QDeclarativeMouseArea::mouseReleaseEvent(), QDeclarativePinchArea::mouseReleaseEvent(), QDeclarativePathView::sendMouseEvent(), QDeclarativeMouseArea::sendMouseEvent(), QDeclarativeFlickable::sendMouseEvent(), QDeclarativePinchArea::sendMouseEvent(), QGraphicsItem::setAcceptedMouseButtons(), QGraphicsItemPrivate::setEnabledHelper(), QDeclarativeFlickable::timerEvent(), and QDeclarativePinchArea::updatePinch().
|
protectedvirtual |
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse move events for the scene.
The default implementation depends on the mouse grabber state. If there is a mouse grabber item, the event is sent to the mouse grabber. If there are any items that accept hover events at the current position, the event is translated into a hover event and accepted; otherwise it's ignored.
Reimplemented in QDeclarativeScene.
Definition at line 4211 of file qgraphicsscene.cpp.
Referenced by event(), and QDeclarativeScene::mouseMoveEvent().
|
protectedvirtual |
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse press events for the scene.
The default implementation depends on the state of the scene. If there is a mouse grabber item, then the event is sent to the mouse grabber. Otherwise, it is forwarded to the topmost item that accepts mouse events at the scene position from the event, and that item promptly becomes the mouse grabber item.
If there is no item at the given position on the scene, the selection area is reset, any focus item loses its input focus, and the event is then ignored.
Reimplemented in QDeclarativeScene.
Definition at line 4186 of file qgraphicsscene.cpp.
Referenced by event(), and QDeclarativeScene::mousePressEvent().
|
protectedvirtual |
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse release events for the scene.
The default implementation depends on the mouse grabber state. If there is no mouse grabber, the event is ignored. Otherwise, if there is a mouse grabber item, the event is sent to the mouse grabber. If this mouse release represents the last pressed button on the mouse, the mouse grabber item then loses the mouse grab.
Reimplemented in QDeclarativeScene.
Definition at line 4241 of file qgraphicsscene.cpp.
Referenced by event(), and QDeclarativeScene::mouseReleaseEvent().
void QGraphicsScene::removeItem | ( | QGraphicsItem * | item | ) |
Removes the item item and all its children from the scene.
The ownership of item is passed on to the caller (i.e., QGraphicsScene will no longer delete item when destroyed).
Definition at line 3062 of file qgraphicsscene.cpp.
Referenced by QmlJSDebugger::LiveSelectionIndicator::clear(), QDeclarativeLoaderPrivate::clear(), QDeclarativeFlickablePrivate::data_clear(), destroyItemGroup(), QDeclarativeVisualItemModel::release(), QDeclarativeVisualDataModel::release(), QGraphicsItem::removeFromIndex(), QGraphicsScenePrivate::removeItemHelper(), QDeclarativeGridView::setFooter(), QDeclarativeListView::setFooter(), QDeclarativeGridView::setHeader(), QDeclarativeListView::setHeader(), QGraphicsProxyWidgetPrivate::unembedSubWindow(), and QmlJSDebugger::LiveSelectionRectangle::~LiveSelectionRectangle().
void QGraphicsScene::render | ( | QPainter * | painter, |
const QRectF & | target = QRectF() , |
||
const QRectF & | source = QRectF() , |
||
Qt::AspectRatioMode | aspectRatioMode = Qt::KeepAspectRatio |
||
) |
Renders the source rect from scene into target, using painter.
This function is useful for capturing the contents of the scene onto a paint device, such as a QImage (e.g., to take a screenshot), or for printing with QPrinter. For example:
If source is a null rect, this function will use sceneRect() to determine what to render. If target is a null rect, the dimensions of painter's paint device will be used.
The source rect contents will be transformed according to aspectRatioMode to fit into the target rect. By default, the aspect ratio is kept, and source is scaled to fit in target.
Definition at line 1779 of file qgraphicsscene.cpp.
QRectF QGraphicsScene::sceneRect | ( | ) | const |
Referenced by render(), and ~QGraphicsScene().
|
signal |
This signal is emitted by QGraphicsScene whenever the scene rect changes.
The rect parameter is the new scene rectangle.
Referenced by setSceneRect(), and ~QGraphicsScene().
QList< QGraphicsItem * > QGraphicsScene::selectedItems | ( | ) | const |
Returns a list of all currently selected items.
The items are returned in no particular order.
Definition at line 2359 of file qgraphicsscene.cpp.
Referenced by QGraphicsItem::mouseMoveEvent(), QGraphicsItem::mouseReleaseEvent(), and selectedItems().
QPainterPath QGraphicsScene::selectionArea | ( | ) | const |
Returns the selection area that was previously set with setSelectionArea(), or an empty QPainterPath if no selection area has been set.
Definition at line 2383 of file qgraphicsscene.cpp.
|
signal |
This signal is emitted by QGraphicsScene whenever the selection changes.
You can call selectedItems() to get the new list of selected items.
The selection changes whenever an item is selected or unselected, a selection area is set, cleared or otherwise changed, if a preselected item is added to the scene, or if a selected item is removed from the scene.
QGraphicsScene emits this signal only once for group selection operations. For example, if you set a selection area, select or unselect a QGraphicsItemGroup, or if you add or remove from the scene a parent item that contains several selected items, selectionChanged() is emitted only once after the operation has completed (instead of once for each item).
Referenced by addItem(), clearSelection(), QGraphicsItem::mouseReleaseEvent(), QGraphicsItem::setSelected(), and setSelectionArea().
bool QGraphicsScene::sendEvent | ( | QGraphicsItem * | item, |
QEvent * | event | ||
) |
Sends event event to item item through possible event filters.
The event is sent only if the item is enabled.
Returns false
if the event was filtered or if the item is disabled. Otherwise returns the value that was returned from the event handler.
Definition at line 5922 of file qgraphicsscene.cpp.
Referenced by QGraphicsScenePrivate::cancelGesturesForChildren(), QGraphicsScenePrivate::enterModal(), event(), QGraphicsScenePrivate::gestureEventHandler(), helpEvent(), QGraphicsScenePrivate::leaveModal(), QGraphicsItem::sceneEvent(), QDeclarativeFlickable::sendMouseEvent(), and QGraphicsScenePrivate::sendTouchBeginEvent().
void QGraphicsScene::setActivePanel | ( | QGraphicsItem * | item | ) |
Activates item, which must be an item in this scene.
If the scene is currently inactive, item remains inactive until the scene becomes active (or, ir item is 0, no item will be activated).
Definition at line 5838 of file qgraphicsscene.cpp.
Referenced by addItem(), QGraphicsItem::setActive(), setActiveWindow(), and QGraphicsItemPrivate::setVisibleHelper().
void QGraphicsScene::setActiveWindow | ( | QGraphicsWidget * | widget | ) |
Activates widget, which must be a widget in this scene.
Definition at line 5874 of file qgraphicsscene.cpp.
void QGraphicsScene::setBackgroundBrush | ( | const QBrush & | brush | ) |
Definition at line 3272 of file qgraphicsscene.cpp.
void QGraphicsScene::setBspTreeDepth | ( | int | depth | ) |
Definition at line 1937 of file qgraphicsscene.cpp.
void QGraphicsScene::setFocus | ( | Qt::FocusReason | focusReason = Qt::OtherFocusReason | ) |
Sets focus on the scene by sending a QFocusEvent to the scene, passing focusReason as the reason.
If the scene regains focus after having previously lost it while an item had focus, the last focus item will receive focus with focusReason as the reason.
If the scene already has focus, this function does nothing.
Definition at line 3160 of file qgraphicsscene.cpp.
Referenced by QGraphicsScenePrivate::sendTouchBeginEvent().
void QGraphicsScene::setFocusItem | ( | QGraphicsItem * | item, |
Qt::FocusReason | focusReason = Qt::OtherFocusReason |
||
) |
Sets the scene's focus item to item, with the focus reason focusReason, after removing focus from any previous item that may have had focus.
If item is 0, or if it either does not accept focus (i.e., it does not have the QGraphicsItem::ItemIsFocusable flag enabled), or is not visible or not enabled, this function only removes focus from any previous focusitem.
If item is not 0, and the scene does not currently have focus (i.e., hasFocus() returns false), this function will call setFocus() automatically.
Definition at line 3128 of file qgraphicsscene.cpp.
Referenced by clearFocus(), QGraphicsItemPrivate::clearFocusHelper(), focusInEvent(), focusNextPrevChild(), focusOutEvent(), QGraphicsItemPrivate::setVisibleHelper(), and wheelEvent().
void QGraphicsScene::setFont | ( | const QFont & | font | ) |
Definition at line 5743 of file qgraphicsscene.cpp.
void QGraphicsScene::setForegroundBrush | ( | const QBrush & | brush | ) |
Definition at line 3311 of file qgraphicsscene.cpp.
void QGraphicsScene::setItemIndexMethod | ( | ItemIndexMethod | method | ) |
Definition at line 1878 of file qgraphicsscene.cpp.
void QGraphicsScene::setPalette | ( | const QPalette & | palette | ) |
Definition at line 5783 of file qgraphicsscene.cpp.
void QGraphicsScene::setSceneRect | ( | const QRectF & | rect | ) |
Definition at line 1729 of file qgraphicsscene.cpp.
Referenced by QGraphicsScene().
Definition at line 137 of file qgraphicsscene.h.
void QGraphicsScene::setSelectionArea | ( | const QPainterPath & | path | ) |
Sets the selection area to path.
This function is deprecated and leads to incorrect results if the scene contains items that ignore transformations. Use the overload that takes a QTransform instead.
Definition at line 2425 of file qgraphicsscene.cpp.
Referenced by setSelectionArea().
void QGraphicsScene::setSelectionArea | ( | const QPainterPath & | path, |
const QTransform & | deviceTransform | ||
) |
Sets the selection area to path.
All items within this area are immediately selected, and all items outside are unselected. You can get the list of all selected items by calling selectedItems().
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
For an item to be selected, it must be marked as selectable (QGraphicsItem::ItemIsSelectable).
Definition at line 2407 of file qgraphicsscene.cpp.
void QGraphicsScene::setSelectionArea | ( | const QPainterPath & | path, |
Qt::ItemSelectionMode | mode | ||
) |
Sets the selection area to path using mode to determine if items are included in the selection area.
Definition at line 2443 of file qgraphicsscene.cpp.
void QGraphicsScene::setSelectionArea | ( | const QPainterPath & | path, |
Qt::ItemSelectionMode | mode, | ||
const QTransform & | deviceTransform | ||
) |
Sets the selection area to path using mode to determine if items are included in the selection area.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
Definition at line 2463 of file qgraphicsscene.cpp.
void QGraphicsScene::setSortCacheEnabled | ( | bool | enabled | ) |
Definition at line 1969 of file qgraphicsscene.cpp.
void QGraphicsScene::setStickyFocus | ( | bool | enabled | ) |
Definition at line 3209 of file qgraphicsscene.cpp.
void QGraphicsScene::setStyle | ( | QStyle * | style | ) |
Sets or replaces the style of the scene to style, and reparents the style to this scene.
Any previously assigned style is deleted. The scene's style defaults to QApplication::style(), and serves as the default for all QGraphicsWidget items in the scene.
Changing the style, either directly by calling this function, or indirectly by calling QApplication::setStyle(), will automatically update the style for all widgets in the scene that do not have a style explicitly assigned to them.
If style is 0, QGraphicsScene will revert to QApplication::style().
Definition at line 5686 of file qgraphicsscene.cpp.
bool QGraphicsScene::stickyFocus | ( | ) | const |
Referenced by QGraphicsScenePrivate::sendTouchBeginEvent(), and setStickyFocus().
QStyle * QGraphicsScene::style | ( | ) | const |
Returns the scene's style, or the same as QApplication::style() if the scene has not been explicitly assigned a style.
Definition at line 5659 of file qgraphicsscene.cpp.
Referenced by QGraphicsWidget::style().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This function is equivalent to calling update(QRectF(x, y, w, h));
Definition at line 232 of file qgraphicsscene.h.
Referenced by event(), invalidate(), QDeclarativeView::paintEvent(), QGraphicsItem::prepareGeometryChange(), setBackgroundBrush(), and setForegroundBrush().
Schedules a redraw of the area rect on the scene.
Definition at line 3356 of file qgraphicsscene.cpp.
QList< QGraphicsView * > QGraphicsScene::views | ( | ) | const |
Returns a list of all the views that display this scene.
Definition at line 3445 of file qgraphicsscene.cpp.
Referenced by QGraphicsScenePrivate::addView(), ShaderEffectItem::checkViewportUpdateMode(), QShortcutMap::correctGraphicsWidgetContext(), QGraphicsItemPrivate::effectiveBoundingRect(), QGraphicsScenePrivate::enableTouchEventsOnViews(), QGraphicsItem::ensureVisible(), invalidate(), QGraphicsScenePrivate::markDirty(), QGraphicsScenePrivate::processDirtyItemsRecursive(), QGraphicsScenePrivate::removeView(), QWidgetPrivate::screenGeometry(), QGraphicsItem::setCursor(), setForegroundBrush(), QGraphicsItem::setInputMethodHints(), QGraphicsScenePrivate::ungrabGesture(), QGraphicsItem::unsetCursor(), QGraphicsScenePrivate::updateInputMethodSensitivityInViews(), QGraphicsItem::updateMicroFocus(), and QGraphicsItemPrivate::updatePaintedViewBoundingRects().
|
protectedvirtual |
This event handler, for event wheelEvent, can be reimplemented in a subclass to receive mouse wheel events for the scene.
By default, the event is delivered to the topmost visible item under the cursor. If ignored, the event propagates to the item beneath, and again until the event is accepted, or it reaches the scene. If no items accept the event, it is ignored.
Definition at line 4304 of file qgraphicsscene.cpp.
Referenced by event().
|
inline |
This convenience function is equivalent to calling sceneRect().
\sa height()
Definition at line 134 of file qgraphicsscene.h.
Definition at line 317 of file qgraphicsscene.h.
|
friend |
Definition at line 310 of file qgraphicsscene.h.
|
friend |
Definition at line 303 of file qgraphicsscene.h.
|
friend |
Definition at line 315 of file qgraphicsscene.h.
|
friend |
Definition at line 304 of file qgraphicsscene.h.
|
friend |
Definition at line 305 of file qgraphicsscene.h.
|
friend |
Definition at line 313 of file qgraphicsscene.h.
Referenced by setItemIndexMethod().
|
friend |
Definition at line 314 of file qgraphicsscene.h.
|
friend |
Definition at line 311 of file qgraphicsscene.h.
|
friend |
Definition at line 312 of file qgraphicsscene.h.
|
friend |
Definition at line 306 of file qgraphicsscene.h.
|
friend |
Definition at line 307 of file qgraphicsscene.h.
|
friend |
Definition at line 308 of file qgraphicsscene.h.
|
friend |
Definition at line 309 of file qgraphicsscene.h.
|
private |
the background brush of the scene.
Set this property to changes the scene's background to a different color, gradient or texture. The default background brush is Qt::NoBrush. The background is drawn before (behind) the items.
Example:
QGraphicsScene::render() calls drawBackground() to draw the scene background. For more detailed control over how the background is drawn, you can reimplement drawBackground() in a subclass of QGraphicsScene.
Definition at line 104 of file qgraphicsscene.h.
|
private |
the depth of QGraphicsScene's BSP index tree
This property has no effect when NoIndex is used.
This value determines the depth of QGraphicsScene's BSP tree. The depth directly affects QGraphicsScene's performance and memory usage; the latter growing exponentially with the depth of the tree. With an optimal tree depth, QGraphicsScene can instantly determine the locality of items, even for scenes with thousands or millions of items. This also greatly improves rendering performance.
By default, the value is 0, in which case Qt will guess a reasonable default depth based on the size, location and number of items in the scene. If these parameters change frequently, however, you may experience slowdowns as QGraphicsScene retunes the depth internally. You can avoid potential slowdowns by fixating the tree depth through setting this property.
The depth of the tree and the size of the scene rectangle decide the granularity of the scene's partitioning. The size of each scene segment is determined by the following algorithm:
The BSP tree has an optimal size when each segment contains between 0 and 10 items.
Definition at line 108 of file qgraphicsscene.h.
|
private |
the scene's default font
This property provides the scene's font. The scene font defaults to, and resolves all its entries from, QApplication::font.
If the scene's font changes, either directly through setFont() or indirectly when the application font changes, QGraphicsScene first sends itself a FontChange event, and it then sends FontChange events to all top-level widget items in the scene. These items respond by resolving their own fonts to the scene, and they then notify their children, who again notify their children, and so on, until all widget items have updated their fonts.
Changing the scene font, (directly or indirectly through QApplication::setFont(),) automatically schedules a redraw the entire scene.
Definition at line 110 of file qgraphicsscene.h.
Referenced by QGraphicsWidgetPrivate::naturalWidgetFont().
|
private |
the foreground brush of the scene.
Change this property to set the scene's foreground to a different color, gradient or texture.
The foreground is drawn after (on top of) the items. The default foreground brush is Qt::NoBrush ( i.e. the foreground is not drawn).
Example:
QGraphicsScene::render() calls drawForeground() to draw the scene foreground. For more detailed control over how the foreground is drawn, you can reimplement the drawForeground() function in a QGraphicsScene subclass.
Definition at line 105 of file qgraphicsscene.h.
|
private |
the item indexing method.
QGraphicsScene applies an indexing algorithm to the scene, to speed up item discovery functions like items() and itemAt(). Indexing is most efficient for static scenes (i.e., where items don't move around). For dynamic scenes, or scenes with many animated items, the index bookkeeping can outweight the fast lookup speeds.
For the common case, the default index method BspTreeIndex works fine. If your scene uses many animations and you are experiencing slowness, you can disable indexing by calling setItemIndexMethod(NoIndex)
.
Definition at line 106 of file qgraphicsscene.h.
|
private |
the scene's default palette
This property provides the scene's palette. The scene palette defaults to, and resolves all its entries from, QApplication::palette.
If the scene's palette changes, either directly through setPalette() or indirectly when the application palette changes, QGraphicsScene first sends itself a PaletteChange event, and it then sends PaletteChange events to all top-level widget items in the scene. These items respond by resolving their own palettes to the scene, and they then notify their children, who again notify their children, and so on, until all widget items have updated their palettes.
Changing the scene palette, (directly or indirectly through QApplication::setPalette(),) automatically schedules a redraw the entire scene.
Definition at line 109 of file qgraphicsscene.h.
Referenced by QGraphicsWidgetPrivate::naturalWidgetPalette().
|
private |
the scene rectangle; the bounding rectangle of the scene
The scene rectangle defines the extent of the scene. It is primarily used by QGraphicsView to determine the view's default scrollable area, and by QGraphicsScene to manage item indexing.
If unset, or if set to a null QRectF, sceneRect() will return the largest bounding rect of all items on the scene since the scene was created (i.e., a rectangle that grows when items are added to or moved in the scene, but never shrinks).
Definition at line 107 of file qgraphicsscene.h.
Referenced by QGraphicsViewPrivate::findItems(), and QWidgetPrivate::screenGeometry().
|
private |
whether sort caching is enabled
Since Qt 4.6, this property has no effect.
Definition at line 111 of file qgraphicsscene.h.
|
private |
whether clicking into the scene background will clear focus
In a QGraphicsScene with stickyFocus set to true, focus will remain unchanged when the user clicks into the scene background or on an item that does not accept focus. Otherwise, focus will be cleared.
By default, this property is false.
Focus changes in response to a mouse press. You can reimplement mousePressEvent() in a subclass of QGraphicsScene to toggle this property based on where the user has clicked.
Definition at line 112 of file qgraphicsscene.h.