QGraphicsScene

Synopsis

Functions

Virtual functions

Slots

Signals

Detailed Description

The PySide.QtGui.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 PySide.QtGui.QGraphicsView for visualizing graphical items, such as lines, rectangles, text, or even custom items, on a 2D surface. PySide.QtGui.QGraphicsScene is part of the Graphics View Framework .

PySide.QtGui.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 PySide.QtGui.QGraphicsView widget, you can either visualize the whole scene, or zoom in and view only parts of the scene.

Example:

scene = QGraphicsScene()
scene.addText("Hello, world!")

view = QGraphicsView(&scene)
view.show()

Note that PySide.QtGui.QGraphicsScene has no visual appearance of its own; it only manages the items. You need to create a PySide.QtGui.QGraphicsView widget to visualize the scene.

To add items to a scene, you start off by constructing a PySide.QtGui.QGraphicsScene object. Then, you have two options: either add your existing PySide.QtGui.QGraphicsItem objects by calling PySide.QtGui.QGraphicsScene.addItem() , or you can call one of the convenience functions PySide.QtGui.QGraphicsScene.addEllipse() , PySide.QtGui.QGraphicsScene.addLine() , PySide.QtGui.QGraphicsScene.addPath() , PySide.QtGui.QGraphicsScene.addPixmap() , PySide.QtGui.QGraphicsScene.addPolygon() , PySide.QtGui.QGraphicsScene.addRect() , or PySide.QtGui.QGraphicsScene.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 PySide.QtGui.QGraphicsView . When the scene changes, (e.g., when an item moves or is transformed) PySide.QtGui.QGraphicsScene emits the PySide.QtGui.QGraphicsScene.changed() signal. To remove an item, call PySide.QtGui.QGraphicsScene.removeItem() .

PySide.QtGui.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 PySide.QtGui.QGraphicsScene.setItemIndexMethod() . For more information about the available indexing algorithms, see the PySide.QtGui.QGraphicsScene.itemIndexMethod() property.

The scene’s bounding rect is set by calling PySide.QtGui.QGraphicsScene.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, PySide.QtGui.QGraphicsScene will use the bounding area of all items, as returned by PySide.QtGui.QGraphicsScene.itemsBoundingRect() , as the scene rect. However, PySide.QtGui.QGraphicsScene.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 PySide.QtGui.QGraphicsScene ‘s greatest strengths is its ability to efficiently determine the location of items. Even with millions of items on the scene, the PySide.QtGui.QGraphicsScene.items() functions can determine the location of an item within few milliseconds. There are several overloads to PySide.QtGui.QGraphicsScene.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 PySide.QtGui.QGraphicsScene.itemAt() function that returns the topmost item at a given position.

PySide.QtGui.QGraphicsScene maintains selection information for the scene. To select items, call PySide.QtGui.QGraphicsScene.setSelectionArea() , and to clear the current selection, call PySide.QtGui.QGraphicsScene.clearSelection() . Call PySide.QtGui.QGraphicsScene.selectedItems() to get the list of all selected items.

Event Handling and Propagation

Another responsibility that PySide.QtGui.QGraphicsScene has, is to propagate events from PySide.QtGui.QGraphicsView . To send an event to a scene, you construct an event that inherits PySide.QtCore.QEvent , and then send it using, for example, QApplication.sendEvent() . PySide.QtGui.QGraphicsScene.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 PySide.QtGui.QGraphicsScene.keyPressEvent() , and mouse press events are handled by PySide.QtGui.QGraphicsScene.mousePressEvent() .

Key events are delivered to the focus item . To set the focus item, you can either call PySide.QtGui.QGraphicsScene.setFocusItem() , passing an item that accepts focus, or the item itself can call QGraphicsItem.setFocus() . Call PySide.QtGui.QGraphicsScene.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 PySide.QtGui.QGraphicsScene.setFocus() is called, or if an item on the scene gains focus, the scene automatically gains focus. If the scene has focus, PySide.QtGui.QGraphicsScene.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 PySide.QtGui.QGraphicsScene.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, PySide.QtGui.QGraphicsScene dispatches hover events . If an item accepts hover events (see QGraphicsItem.acceptHoverEvents() ), it will receive a GraphicsSceneHoverEnter event when the mouse enters its area. As the mouse continues moving inside the item’s area, PySide.QtGui.QGraphicsScene will send it GraphicsSceneHoverMove events. When the mouse leaves the item’s area, the item will receive a 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 PySide.QtGui.QGraphicsScene.mouseGrabberItem() to determine what item is currently grabbing the mouse.

class PySide.QtGui.QGraphicsScene([parent=None])
class PySide.QtGui.QGraphicsScene(sceneRect[, parent=None])
class PySide.QtGui.QGraphicsScene(x, y, width, height[, parent=None])
Parameters:

Constructs a PySide.QtGui.QGraphicsScene object. The parent parameter is passed to PySide.QtCore.QObject ‘s constructor.

Constructs a PySide.QtGui.QGraphicsScene object, using sceneRect for its scene rectangle. The parent parameter is passed to PySide.QtCore.QObject ‘s constructor.

Constructs a PySide.QtGui.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 PySide.QtCore.QObject ‘s constructor.

PySide.QtGui.QGraphicsScene.SceneLayer

This enum describes the rendering layers in a PySide.QtGui.QGraphicsScene . When PySide.QtGui.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 PySide.QtGui.QGraphicsScene.invalidate() or QGraphicsView.invalidateScene() .

Constant Description
QGraphicsScene.ItemLayer The item layer. PySide.QtGui.QGraphicsScene renders all items are in this layer by calling the virtual function PySide.QtGui.QGraphicsScene.drawItems() . The item layer is drawn after the background layer, but before the foreground layer.
QGraphicsScene.BackgroundLayer The background layer. PySide.QtGui.QGraphicsScene renders the scene’s background in this layer by calling the virtual function PySide.QtGui.QGraphicsScene.drawBackground() . The background layer is drawn first of all layers.
QGraphicsScene.ForegroundLayer The foreground layer. PySide.QtGui.QGraphicsScene renders the scene’s foreground in this layer by calling the virtual function PySide.QtGui.QGraphicsScene.drawForeground() . The foreground layer is drawn last of all layers.
QGraphicsScene.AllLayers All layers; this value represents a combination of all three layers.
PySide.QtGui.QGraphicsScene.ItemIndexMethod

This enum describes the indexing algorithms PySide.QtGui.QGraphicsScene provides for managing positional information about items on the scene.

Constant Description
QGraphicsScene.BspTreeIndex A Binary Space Partitioning tree is applied. All PySide.QtGui.QGraphicsScene ‘s item location algorithms are of an order close to logarithmic complexity, by making use of binary search. Adding, moving and removing items is logarithmic. This approach is best for static scenes (i.e., scenes where most items do not move).
QGraphicsScene.NoIndex No index is applied. Item location is of linear complexity, as all items on the scene are searched. Adding, moving and removing items, however, is done in constant time. This approach is ideal for dynamic scenes, where many items are added, moved or removed continuously.
PySide.QtGui.QGraphicsScene.activePanel()
Return type:PySide.QtGui.QGraphicsItem

Returns the current active panel, or 0 if no panel is currently active.

PySide.QtGui.QGraphicsScene.activeWindow()
Return type:PySide.QtGui.QGraphicsWidget

Returns the current active window, or 0 if no window is currently active.

PySide.QtGui.QGraphicsScene.addEllipse(rect[, pen=QPen()[, brush=QBrush()]])
Parameters:
Return type:

PySide.QtGui.QGraphicsEllipseItem

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), PySide.QtGui.QGraphicsScene will emit PySide.QtGui.QGraphicsScene.changed() once control goes back to the event loop.

PySide.QtGui.QGraphicsScene.addEllipse(x, y, w, h[, pen=QPen()[, brush=QBrush()]])
Parameters:
Return type:

PySide.QtGui.QGraphicsEllipseItem

This convenience function is equivalent to calling addEllipse( PySide.QtCore.QRectF (x , y , w , h ), pen , brush ).

PySide.QtGui.QGraphicsScene.addItem(item)
Parameters:itemPySide.QtGui.QGraphicsItem

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), PySide.QtGui.QGraphicsScene will emit PySide.QtGui.QGraphicsScene.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.

PySide.QtGui.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), PySide.QtGui.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.

PySide.QtGui.QGraphicsScene.addLine(x1, y1, x2, y2[, pen=QPen()])
Parameters:
  • x1PySide.QtCore.qreal
  • y1PySide.QtCore.qreal
  • x2PySide.QtCore.qreal
  • y2PySide.QtCore.qreal
  • penPySide.QtGui.QPen
Return type:

PySide.QtGui.QGraphicsLineItem

This convenience function is equivalent to calling addLine( PySide.QtCore.QLineF (x1 , y1 , x2 , y2 ), pen ).

PySide.QtGui.QGraphicsScene.addLine(line[, pen=QPen()])
Parameters:
Return type:

PySide.QtGui.QGraphicsLineItem

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), PySide.QtGui.QGraphicsScene will emit PySide.QtGui.QGraphicsScene.changed() once control goes back to the event loop.

PySide.QtGui.QGraphicsScene.addPath(path[, pen=QPen()[, brush=QBrush()]])
Parameters:
Return type:

PySide.QtGui.QGraphicsPathItem

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), PySide.QtGui.QGraphicsScene will emit PySide.QtGui.QGraphicsScene.changed() once control goes back to the event loop.

PySide.QtGui.QGraphicsScene.addPixmap(pixmap)
Parameters:pixmapPySide.QtGui.QPixmap
Return type:PySide.QtGui.QGraphicsPixmapItem

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), PySide.QtGui.QGraphicsScene will emit PySide.QtGui.QGraphicsScene.changed() once control goes back to the event loop.

PySide.QtGui.QGraphicsScene.addPolygon(polygon[, pen=QPen()[, brush=QBrush()]])
Parameters:
Return type:

PySide.QtGui.QGraphicsPolygonItem

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), PySide.QtGui.QGraphicsScene will emit PySide.QtGui.QGraphicsScene.changed() once control goes back to the event loop.

PySide.QtGui.QGraphicsScene.addRect(x, y, w, h[, pen=QPen()[, brush=QBrush()]])
Parameters:
Return type:

PySide.QtGui.QGraphicsRectItem

This convenience function is equivalent to calling addRect( PySide.QtCore.QRectF (x , y , w , h ), pen , brush ).

PySide.QtGui.QGraphicsScene.addRect(rect[, pen=QPen()[, brush=QBrush()]])
Parameters:
Return type:

PySide.QtGui.QGraphicsRectItem

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 PySide.QtCore.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), PySide.QtGui.QGraphicsScene will emit PySide.QtGui.QGraphicsScene.changed() once control goes back to the event loop.

PySide.QtGui.QGraphicsScene.addSimpleText(text[, font=QFont()])
Parameters:
Return type:

PySide.QtGui.QGraphicsSimpleTextItem

Creates and adds a PySide.QtGui.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), PySide.QtGui.QGraphicsScene will emit PySide.QtGui.QGraphicsScene.changed() once control goes back to the event loop.

PySide.QtGui.QGraphicsScene.addText(text[, font=QFont()])
Parameters:
Return type:

PySide.QtGui.QGraphicsTextItem

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), PySide.QtGui.QGraphicsScene will emit PySide.QtGui.QGraphicsScene.changed() once control goes back to the event loop.

PySide.QtGui.QGraphicsScene.addWidget(widget[, wFlags=0])
Parameters:
Return type:

PySide.QtGui.QGraphicsProxyWidget

PySide.QtGui.QGraphicsScene.advance()

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.

PySide.QtGui.QGraphicsScene.backgroundBrush()
Return type:PySide.QtGui.QBrush

This property holds 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:

scene = QGraphicsScene()
view = QGraphicsView(scene)
view.show()

# a blue background
scene.setBackgroundBrush(Qt.blue)

# a gradient background
gradient = QRadialGradient(0, 0, 10)
gradient.setSpread(QGradient.RepeatSpread)
scene.setBackgroundBrush(gradient)

QGraphicsScene.render() calls PySide.QtGui.QGraphicsScene.drawBackground() to draw the scene background. For more detailed control over how the background is drawn, you can reimplement PySide.QtGui.QGraphicsScene.drawBackground() in a subclass of PySide.QtGui.QGraphicsScene .

PySide.QtGui.QGraphicsScene.bspTreeDepth()
Return type:PySide.QtCore.int

This property holds the depth of PySide.QtGui.QGraphicsScene ‘s BSP index tree.

This property has no effect when NoIndex is used.

This value determines the depth of PySide.QtGui.QGraphicsScene ‘s BSP tree. The depth directly affects PySide.QtGui.QGraphicsScene ‘s performance and memory usage; the latter growing exponentially with the depth of the tree. With an optimal tree depth, PySide.QtGui.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 PySide.QtGui.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:

segmentSize = sceneRect().size() / math.pow(2, depth - 1)

The BSP tree has an optimal size when each segment contains between 0 and 10 items.

PySide.QtGui.QGraphicsScene.changed(region)
Parameters:region
PySide.QtGui.QGraphicsScene.clear()

Removes and deletes all items from the scene, but otherwise leaves the state of the scene unchanged.

PySide.QtGui.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.

PySide.QtGui.QGraphicsScene.clearSelection()

Clears the current selection.

PySide.QtGui.QGraphicsScene.collidingItems(item[, mode=Qt.IntersectsItemShape])
Parameters:
Return type:

PySide.QtGui.QGraphicsScene.contextMenuEvent(event)
Parameters:eventPySide.QtGui.QGraphicsSceneContextMenuEvent

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.

PySide.QtGui.QGraphicsScene.createItemGroup(items)
Parameters:items
Return type:PySide.QtGui.QGraphicsItemGroup
PySide.QtGui.QGraphicsScene.destroyItemGroup(group)
Parameters:groupPySide.QtGui.QGraphicsItemGroup

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.

PySide.QtGui.QGraphicsScene.dragEnterEvent(event)
Parameters:eventPySide.QtGui.QGraphicsSceneDragDropEvent

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.

PySide.QtGui.QGraphicsScene.dragLeaveEvent(event)
Parameters:eventPySide.QtGui.QGraphicsSceneDragDropEvent

This event handler, for event event , can be reimplemented in a subclass to receive drag leave events for the scene.

PySide.QtGui.QGraphicsScene.dragMoveEvent(event)
Parameters:eventPySide.QtGui.QGraphicsSceneDragDropEvent

This event handler, for event event , can be reimplemented in a subclass to receive drag move events for the scene.

PySide.QtGui.QGraphicsScene.drawBackground(painter, rect)
Parameters:

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 PySide.QtGui.QGraphicsScene.setBackgroundBrush() instead.

See also

PySide.QtGui.QGraphicsScene.drawForeground() PySide.QtGui.QGraphicsScene.drawItems()

PySide.QtGui.QGraphicsScene.drawForeground(painter, rect)
Parameters:

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 PySide.QtGui.QGraphicsScene.setForegroundBrush() instead.

See also

PySide.QtGui.QGraphicsScene.drawBackground() PySide.QtGui.QGraphicsScene.drawItems()

PySide.QtGui.QGraphicsScene.dropEvent(event)
Parameters:eventPySide.QtGui.QGraphicsSceneDragDropEvent

This event handler, for event event , can be reimplemented in a subclass to receive drop events for the scene.

PySide.QtGui.QGraphicsScene.focusInEvent(event)
Parameters:eventPySide.QtGui.QFocusEvent

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.

PySide.QtGui.QGraphicsScene.focusItem()
Return type:PySide.QtGui.QGraphicsItem

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.

PySide.QtGui.QGraphicsScene.focusNextPrevChild(next)
Parameters:nextPySide.QtCore.bool
Return type:PySide.QtCore.bool

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 PySide.QtGui.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() .

PySide.QtGui.QGraphicsScene.focusOutEvent(event)
Parameters:eventPySide.QtGui.QFocusEvent

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.

PySide.QtGui.QGraphicsScene.font()
Return type:PySide.QtGui.QFont

This property holds 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 PySide.QtGui.QGraphicsScene.setFont() or indirectly when the application font changes, PySide.QtGui.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.

PySide.QtGui.QGraphicsScene.foregroundBrush()
Return type:PySide.QtGui.QBrush

This property holds 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:

scene = QGraphicsScene()
view = QGraphicsView(scene)
view.show()

# a white semi-transparent foreground
scene.setForegroundBrush(QColor(255, 255, 255, 127))

# a grid foreground
scene.setForegroundBrush(QBrush(Qt.lightGray, Qt.CrossPattern))

QGraphicsScene.render() calls PySide.QtGui.QGraphicsScene.drawForeground() to draw the scene foreground. For more detailed control over how the foreground is drawn, you can reimplement the PySide.QtGui.QGraphicsScene.drawForeground() function in a PySide.QtGui.QGraphicsScene subclass.

PySide.QtGui.QGraphicsScene.hasFocus()
Return type:PySide.QtCore.bool

Returns true if the scene has focus; otherwise returns false. If the scene has focus, it will will forward key events from PySide.QtGui.QKeyEvent to any item that has focus.

PySide.QtGui.QGraphicsScene.height()
Return type:PySide.QtCore.qreal

This convenience function is equivalent to calling sceneRect().height() .

PySide.QtGui.QGraphicsScene.helpEvent(event)
Parameters:eventPySide.QtGui.QGraphicsSceneHelpEvent

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.

PySide.QtGui.QGraphicsScene.inputMethodEvent(event)
Parameters:eventPySide.QtGui.QInputMethodEvent

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 PySide.QtGui.QGraphicsScene.focusItem() . If no item currently has focus or the current focus item does not accept input methods, this function does nothing.

PySide.QtGui.QGraphicsScene.inputMethodQuery(query)
Parameters:queryPySide.QtCore.Qt.InputMethodQuery
Return type:object
PySide.QtGui.QGraphicsScene.invalidate([rect=QRectF()[, layers=QGraphicsScene.AllLayers]])
Parameters:
PySide.QtGui.QGraphicsScene.invalidate(x, y, w, h[, layers=QGraphicsScene.AllLayers])
Parameters:
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal
  • wPySide.QtCore.qreal
  • hPySide.QtCore.qreal
  • layersPySide.QtGui.QGraphicsScene.SceneLayers
PySide.QtGui.QGraphicsScene.isActive()
Return type:PySide.QtCore.bool

Returns true if the scene is active (e.g., it’s viewed by at least one PySide.QtGui.QGraphicsView that is active); otherwise returns false.

PySide.QtGui.QGraphicsScene.isSortCacheEnabled()
Return type:PySide.QtCore.bool

This property holds whether sort caching is enabled.

Since Qt 4.6, this property has no effect.

PySide.QtGui.QGraphicsScene.itemAt(x, y, deviceTransform)
Parameters:
Return type:

PySide.QtGui.QGraphicsItem

This is an overloaded function.

Returns the topmost item at the position specified by (x , y ), 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.

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

PySide.QtGui.QGraphicsScene.itemAt(x, y)
Parameters:
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal
Return type:

PySide.QtGui.QGraphicsItem

This is an overloaded function.

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

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

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

PySide.QtGui.QGraphicsScene.itemAt(pos, deviceTransform)
Parameters:
Return type:

PySide.QtGui.QGraphicsItem

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.

PySide.QtGui.QGraphicsScene.itemAt(pos)
Parameters:posPySide.QtCore.QPointF
Return type:PySide.QtGui.QGraphicsItem

This is an overloaded function.

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

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

PySide.QtGui.QGraphicsScene.itemIndexMethod()
Return type:PySide.QtGui.QGraphicsScene.ItemIndexMethod

This property holds the item indexing method..

PySide.QtGui.QGraphicsScene applies an indexing algorithm to the scene, to speed up item discovery functions like PySide.QtGui.QGraphicsScene.items() and PySide.QtGui.QGraphicsScene.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) .

PySide.QtGui.QGraphicsScene.items(rect[, mode=Qt.IntersectsItemShape])
Parameters:
Return type:

PySide.QtGui.QGraphicsScene.items(rect, mode, order[, deviceTransform=QTransform()])
Parameters:
Return type:

PySide.QtGui.QGraphicsScene.items(x, y, w, h[, mode=Qt.IntersectsItemShape])
Parameters:
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal
  • wPySide.QtCore.qreal
  • hPySide.QtCore.qreal
  • modePySide.QtCore.Qt.ItemSelectionMode
Return type:

PySide.QtGui.QGraphicsScene.items(x, y, w, h, mode, order[, deviceTransform=QTransform()])
Parameters:
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal
  • wPySide.QtCore.qreal
  • hPySide.QtCore.qreal
  • modePySide.QtCore.Qt.ItemSelectionMode
  • orderPySide.QtCore.Qt.SortOrder
  • deviceTransformPySide.QtGui.QTransform
Return type:

PySide.QtGui.QGraphicsScene.items(polygon, mode, order[, deviceTransform=QTransform()])
Parameters:
Return type:

PySide.QtGui.QGraphicsScene.items(polygon[, mode=Qt.IntersectsItemShape])
Parameters:
Return type:

PySide.QtGui.QGraphicsScene.items(order)
Parameters:orderPySide.QtCore.Qt.SortOrder
Return type:
PySide.QtGui.QGraphicsScene.items(path[, mode=Qt.IntersectsItemShape])
Parameters:
Return type:

PySide.QtGui.QGraphicsScene.items()
Return type:

Returns a list of all items in the scene in descending stacking order.

PySide.QtGui.QGraphicsScene.items(pos, mode, order[, deviceTransform=QTransform()])
Parameters:
Return type:

PySide.QtGui.QGraphicsScene.items(path, mode, order[, deviceTransform=QTransform()])
Parameters:
Return type:

PySide.QtGui.QGraphicsScene.items(pos)
Parameters:posPySide.QtCore.QPointF
Return type:

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 PySide.QtGui.QTransform instead.

PySide.QtGui.QGraphicsScene.itemsBoundingRect()
Return type:PySide.QtCore.QRectF

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.

PySide.QtGui.QGraphicsScene.keyPressEvent(event)
Parameters:eventPySide.QtGui.QKeyEvent

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.

PySide.QtGui.QGraphicsScene.keyReleaseEvent(event)
Parameters:eventPySide.QtGui.QKeyEvent

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.

PySide.QtGui.QGraphicsScene.mouseDoubleClickEvent(event)
Parameters:eventPySide.QtGui.QGraphicsSceneMouseEvent

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 PySide.QtGui.QGraphicsScene.mousePressEvent() .

PySide.QtGui.QGraphicsScene.mouseGrabberItem()
Return type:PySide.QtGui.QGraphicsItem

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:

  • If the item receives a mouse release event when there are no other buttons pressed, it loses the mouse grab.
  • If the item becomes invisible (i.e., someone calls item->setVisible(false)), or if it becomes disabled (i.e., someone calls item->setEnabled(false)), it loses the mouse grab.
  • If the item is removed from the scene, 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).

PySide.QtGui.QGraphicsScene.mouseMoveEvent(event)
Parameters:eventPySide.QtGui.QGraphicsSceneMouseEvent

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.

PySide.QtGui.QGraphicsScene.mousePressEvent(event)
Parameters:eventPySide.QtGui.QGraphicsSceneMouseEvent

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.

PySide.QtGui.QGraphicsScene.mouseReleaseEvent(event)
Parameters:eventPySide.QtGui.QGraphicsSceneMouseEvent

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.

PySide.QtGui.QGraphicsScene.palette()
Return type:PySide.QtGui.QPalette

This property holds 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 PySide.QtGui.QGraphicsScene.setPalette() or indirectly when the application palette changes, PySide.QtGui.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.

PySide.QtGui.QGraphicsScene.removeItem(item)
Parameters:itemPySide.QtGui.QGraphicsItem

Removes the item item and all its children from the scene. The ownership of item is passed on to the caller (i.e., PySide.QtGui.QGraphicsScene will no longer delete item when destroyed).

PySide.QtGui.QGraphicsScene.render(painter[, target=QRectF()[, source=QRectF()[, aspectRatioMode=Qt.KeepAspectRatio]]])
Parameters:
PySide.QtGui.QGraphicsScene.sceneRect()
Return type:PySide.QtCore.QRectF

This property holds the scene rectangle; the bounding rectangle of the scene.

The scene rectangle defines the extent of the scene. It is primarily used by PySide.QtGui.QGraphicsView to determine the view’s default scrollable area, and by PySide.QtGui.QGraphicsScene to manage item indexing.

If unset, or if set to a null PySide.QtCore.QRectF , PySide.QtGui.QGraphicsScene.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).

PySide.QtGui.QGraphicsScene.sceneRectChanged(rect)
Parameters:rectPySide.QtCore.QRectF
PySide.QtGui.QGraphicsScene.selectedItems()
Return type:

Returns a list of all currently selected items. The items are returned in no particular order.

PySide.QtGui.QGraphicsScene.selectionArea()
Return type:PySide.QtGui.QPainterPath

Returns the selection area that was previously set with PySide.QtGui.QGraphicsScene.setSelectionArea() , or an empty PySide.QtGui.QPainterPath if no selection area has been set.

PySide.QtGui.QGraphicsScene.selectionChanged()
PySide.QtGui.QGraphicsScene.sendEvent(item, event)
Parameters:
Return type:

PySide.QtCore.bool

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.

PySide.QtGui.QGraphicsScene.setActivePanel(item)
Parameters:itemPySide.QtGui.QGraphicsItem

Activates item , which must be an item in this scene. You can also pass 0 for item , in which case PySide.QtGui.QGraphicsScene will deactivate any currently active panel.

If the scene is currently inactive, item remains inactive until the scene becomes active (or, ir item is 0, no item will be activated).

PySide.QtGui.QGraphicsScene.setActiveWindow(widget)
Parameters:widgetPySide.QtGui.QGraphicsWidget

Activates widget , which must be a widget in this scene. You can also pass 0 for widget , in which case PySide.QtGui.QGraphicsScene will deactivate any currently active window.

PySide.QtGui.QGraphicsScene.setBackgroundBrush(brush)
Parameters:brushPySide.QtGui.QBrush

This property holds 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:

scene = QGraphicsScene()
view = QGraphicsView(scene)
view.show()

# a blue background
scene.setBackgroundBrush(Qt.blue)

# a gradient background
gradient = QRadialGradient(0, 0, 10)
gradient.setSpread(QGradient.RepeatSpread)
scene.setBackgroundBrush(gradient)

QGraphicsScene.render() calls PySide.QtGui.QGraphicsScene.drawBackground() to draw the scene background. For more detailed control over how the background is drawn, you can reimplement PySide.QtGui.QGraphicsScene.drawBackground() in a subclass of PySide.QtGui.QGraphicsScene .

PySide.QtGui.QGraphicsScene.setBspTreeDepth(depth)
Parameters:depthPySide.QtCore.int

This property holds the depth of PySide.QtGui.QGraphicsScene ‘s BSP index tree.

This property has no effect when NoIndex is used.

This value determines the depth of PySide.QtGui.QGraphicsScene ‘s BSP tree. The depth directly affects PySide.QtGui.QGraphicsScene ‘s performance and memory usage; the latter growing exponentially with the depth of the tree. With an optimal tree depth, PySide.QtGui.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 PySide.QtGui.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:

segmentSize = sceneRect().size() / math.pow(2, depth - 1)

The BSP tree has an optimal size when each segment contains between 0 and 10 items.

PySide.QtGui.QGraphicsScene.setFocus([focusReason=Qt.OtherFocusReason])
Parameters:focusReasonPySide.QtCore.Qt.FocusReason
PySide.QtGui.QGraphicsScene.setFocusItem(item[, focusReason=Qt.OtherFocusReason])
Parameters:
PySide.QtGui.QGraphicsScene.setFont(font)
Parameters:fontPySide.QtGui.QFont

This property holds 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 PySide.QtGui.QGraphicsScene.setFont() or indirectly when the application font changes, PySide.QtGui.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.

PySide.QtGui.QGraphicsScene.setForegroundBrush(brush)
Parameters:brushPySide.QtGui.QBrush

This property holds 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:

scene = QGraphicsScene()
view = QGraphicsView(scene)
view.show()

# a white semi-transparent foreground
scene.setForegroundBrush(QColor(255, 255, 255, 127))

# a grid foreground
scene.setForegroundBrush(QBrush(Qt.lightGray, Qt.CrossPattern))

QGraphicsScene.render() calls PySide.QtGui.QGraphicsScene.drawForeground() to draw the scene foreground. For more detailed control over how the foreground is drawn, you can reimplement the PySide.QtGui.QGraphicsScene.drawForeground() function in a PySide.QtGui.QGraphicsScene subclass.

PySide.QtGui.QGraphicsScene.setItemIndexMethod(method)
Parameters:methodPySide.QtGui.QGraphicsScene.ItemIndexMethod

This property holds the item indexing method..

PySide.QtGui.QGraphicsScene applies an indexing algorithm to the scene, to speed up item discovery functions like PySide.QtGui.QGraphicsScene.items() and PySide.QtGui.QGraphicsScene.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) .

PySide.QtGui.QGraphicsScene.setPalette(palette)
Parameters:palettePySide.QtGui.QPalette

This property holds 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 PySide.QtGui.QGraphicsScene.setPalette() or indirectly when the application palette changes, PySide.QtGui.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.

PySide.QtGui.QGraphicsScene.setSceneRect(x, y, w, h)
Parameters:
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal
  • wPySide.QtCore.qreal
  • hPySide.QtCore.qreal
PySide.QtGui.QGraphicsScene.setSceneRect(rect)
Parameters:rectPySide.QtCore.QRectF

This property holds the scene rectangle; the bounding rectangle of the scene.

The scene rectangle defines the extent of the scene. It is primarily used by PySide.QtGui.QGraphicsView to determine the view’s default scrollable area, and by PySide.QtGui.QGraphicsScene to manage item indexing.

If unset, or if set to a null PySide.QtCore.QRectF , PySide.QtGui.QGraphicsScene.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).

PySide.QtGui.QGraphicsScene.setSelectionArea(path, mode, deviceTransform)
Parameters:
PySide.QtGui.QGraphicsScene.setSelectionArea(path, deviceTransform)
Parameters:

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 PySide.QtGui.QGraphicsScene.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 ).

PySide.QtGui.QGraphicsScene.setSelectionArea(path, mode)
Parameters:
PySide.QtGui.QGraphicsScene.setSelectionArea(path)
Parameters:pathPySide.QtGui.QPainterPath

This is an overloaded function.

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 PySide.QtGui.QTransform instead.

PySide.QtGui.QGraphicsScene.setSortCacheEnabled(enabled)
Parameters:enabledPySide.QtCore.bool

This property holds whether sort caching is enabled.

Since Qt 4.6, this property has no effect.

PySide.QtGui.QGraphicsScene.setStickyFocus(enabled)
Parameters:enabledPySide.QtCore.bool

This property holds whether clicking into the scene background will clear focus.

In a PySide.QtGui.QGraphicsScene with PySide.QtGui.QGraphicsScene.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 PySide.QtGui.QGraphicsScene.mousePressEvent() in a subclass of PySide.QtGui.QGraphicsScene to toggle this property based on where the user has clicked.

PySide.QtGui.QGraphicsScene.setStyle(style)
Parameters:stylePySide.QtGui.QStyle

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 PySide.QtGui.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, PySide.QtGui.QGraphicsScene will revert to QApplication.style() .

PySide.QtGui.QGraphicsScene.stickyFocus()
Return type:PySide.QtCore.bool

This property holds whether clicking into the scene background will clear focus.

In a PySide.QtGui.QGraphicsScene with PySide.QtGui.QGraphicsScene.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 PySide.QtGui.QGraphicsScene.mousePressEvent() in a subclass of PySide.QtGui.QGraphicsScene to toggle this property based on where the user has clicked.

PySide.QtGui.QGraphicsScene.style()
Return type:PySide.QtGui.QStyle

Returns the scene’s style, or the same as QApplication.style() if the scene has not been explicitly assigned a style.

PySide.QtGui.QGraphicsScene.update(x, y, w, h)
Parameters:
  • xPySide.QtCore.qreal
  • yPySide.QtCore.qreal
  • wPySide.QtCore.qreal
  • hPySide.QtCore.qreal

This is an overloaded function.

This function is equivalent to calling update( PySide.QtCore.QRectF (x , y , w , h ));

PySide.QtGui.QGraphicsScene.update([rect=QRectF()])
Parameters:rectPySide.QtCore.QRectF

Schedules a redraw of the area rect on the scene.

PySide.QtGui.QGraphicsScene.views()
Return type:

Returns a list of all the views that display this scene.

PySide.QtGui.QGraphicsScene.wheelEvent(event)
Parameters:eventPySide.QtGui.QGraphicsSceneWheelEvent

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.

PySide.QtGui.QGraphicsScene.width()
Return type:PySide.QtCore.qreal

This convenience function is equivalent to calling PySide.QtGui.QGraphicsScene.sceneRect() . PySide.QtGui.QGraphicsScene.width() .