<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QGraphicsScene Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QGraphicsScene Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QGraphicsScene class provides a surface for managing a large number of 2D graphical items. <a href="#details">More...</a></p> <p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qgraphicsscene.html#ItemIndexMethod-enum">ItemIndexMethod</a></b> { BspTreeIndex, NoIndex }</li><li><div class="fn" />enum <b><a href="qgraphicsscene.html#SceneLayer-enum">SceneLayer</a></b> { ItemLayer, BackgroundLayer, ForegroundLayer, AllLayers }</li><li><div class="fn" />class <b><a href="qgraphicsscene-scenelayers.html">SceneLayers</a></b></li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qgraphicsscene.html#QGraphicsScene">__init__</a></b> (<i>self</i>, QObject <i>parent</i> = None)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#QGraphicsScene-2">__init__</a></b> (<i>self</i>, QRectF <i>sceneRect</i>, QObject <i>parent</i> = None)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#QGraphicsScene-3">__init__</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>width</i>, float <i>height</i>, QObject <i>parent</i> = None)</li><li><div class="fn" />QGraphicsItem <b><a href="qgraphicsscene.html#activePanel">activePanel</a></b> (<i>self</i>)</li><li><div class="fn" />QGraphicsWidget <b><a href="qgraphicsscene.html#activeWindow">activeWindow</a></b> (<i>self</i>)</li><li><div class="fn" />QGraphicsEllipseItem <b><a href="qgraphicsscene.html#addEllipse">addEllipse</a></b> (<i>self</i>, QRectF <i>rect</i>, QPen <i>pen</i> = QPen(), QBrush <i>brush</i> = QBrush())</li><li><div class="fn" />QGraphicsEllipseItem <b><a href="qgraphicsscene.html#addEllipse-2">addEllipse</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, QPen <i>pen</i> = QPen(), QBrush <i>brush</i> = QBrush())</li><li><div class="fn" /><b><a href="qgraphicsscene.html#addItem">addItem</a></b> (<i>self</i>, QGraphicsItem <i>item</i>)</li><li><div class="fn" />QGraphicsLineItem <b><a href="qgraphicsscene.html#addLine">addLine</a></b> (<i>self</i>, QLineF <i>line</i>, QPen <i>pen</i> = QPen())</li><li><div class="fn" />QGraphicsLineItem <b><a href="qgraphicsscene.html#addLine-2">addLine</a></b> (<i>self</i>, float <i>x1</i>, float <i>y1</i>, float <i>x2</i>, float <i>y2</i>, QPen <i>pen</i> = QPen())</li><li><div class="fn" />QGraphicsPathItem <b><a href="qgraphicsscene.html#addPath">addPath</a></b> (<i>self</i>, QPainterPath <i>path</i>, QPen <i>pen</i> = QPen(), QBrush <i>brush</i> = QBrush())</li><li><div class="fn" />QGraphicsPixmapItem <b><a href="qgraphicsscene.html#addPixmap">addPixmap</a></b> (<i>self</i>, QPixmap <i>pixmap</i>)</li><li><div class="fn" />QGraphicsPolygonItem <b><a href="qgraphicsscene.html#addPolygon">addPolygon</a></b> (<i>self</i>, QPolygonF <i>polygon</i>, QPen <i>pen</i> = QPen(), QBrush <i>brush</i> = QBrush())</li><li><div class="fn" />QGraphicsRectItem <b><a href="qgraphicsscene.html#addRect">addRect</a></b> (<i>self</i>, QRectF <i>rect</i>, QPen <i>pen</i> = QPen(), QBrush <i>brush</i> = QBrush())</li><li><div class="fn" />QGraphicsRectItem <b><a href="qgraphicsscene.html#addRect-2">addRect</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, QPen <i>pen</i> = QPen(), QBrush <i>brush</i> = QBrush())</li><li><div class="fn" />QGraphicsSimpleTextItem <b><a href="qgraphicsscene.html#addSimpleText">addSimpleText</a></b> (<i>self</i>, QString <i>text</i>, QFont <i>font</i> = QFont())</li><li><div class="fn" />QGraphicsTextItem <b><a href="qgraphicsscene.html#addText">addText</a></b> (<i>self</i>, QString <i>text</i>, QFont <i>font</i> = QFont())</li><li><div class="fn" />QGraphicsProxyWidget <b><a href="qgraphicsscene.html#addWidget">addWidget</a></b> (<i>self</i>, QWidget <i>widget</i>, Qt.WindowFlags <i>flags</i> = 0)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#advance">advance</a></b> (<i>self</i>)</li><li><div class="fn" />QBrush <b><a href="qgraphicsscene.html#backgroundBrush">backgroundBrush</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qgraphicsscene.html#bspTreeDepth">bspTreeDepth</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#clearFocus">clearFocus</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#clearSelection">clearSelection</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#collidingItems">collidingItems</a></b> (<i>self</i>, QGraphicsItem <i>item</i>, Qt.ItemSelectionMode <i>mode</i> = Qt.IntersectsItemShape)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#contextMenuEvent">contextMenuEvent</a></b> (<i>self</i>, QGraphicsSceneContextMenuEvent <i>event</i>)</li><li><div class="fn" />QGraphicsItemGroup <b><a href="qgraphicsscene.html#createItemGroup">createItemGroup</a></b> (<i>self</i>, list-of-QGraphicsItem <i>items</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#destroyItemGroup">destroyItemGroup</a></b> (<i>self</i>, QGraphicsItemGroup <i>group</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#dragEnterEvent">dragEnterEvent</a></b> (<i>self</i>, QGraphicsSceneDragDropEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#dragLeaveEvent">dragLeaveEvent</a></b> (<i>self</i>, QGraphicsSceneDragDropEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#dragMoveEvent">dragMoveEvent</a></b> (<i>self</i>, QGraphicsSceneDragDropEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#drawBackground">drawBackground</a></b> (<i>self</i>, QPainter <i>painter</i>, QRectF <i>rect</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#drawForeground">drawForeground</a></b> (<i>self</i>, QPainter <i>painter</i>, QRectF <i>rect</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#drawItems">drawItems</a></b> (<i>self</i>, QPainter <i>painter</i>, list-of-QGraphicsItem <i>items</i>, list-of-QStyleOptionGraphicsItem <i>options</i>, QWidget <i>widget</i> = None)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#dropEvent">dropEvent</a></b> (<i>self</i>, QGraphicsSceneDragDropEvent <i>event</i>)</li><li><div class="fn" />bool <b><a href="qgraphicsscene.html#event">event</a></b> (<i>self</i>, QEvent <i>event</i>)</li><li><div class="fn" />bool <b><a href="qgraphicsscene.html#eventFilter">eventFilter</a></b> (<i>self</i>, QObject <i>watched</i>, QEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#focusInEvent">focusInEvent</a></b> (<i>self</i>, QFocusEvent <i>event</i>)</li><li><div class="fn" />QGraphicsItem <b><a href="qgraphicsscene.html#focusItem">focusItem</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qgraphicsscene.html#focusNextPrevChild">focusNextPrevChild</a></b> (<i>self</i>, bool <i>next</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#focusOutEvent">focusOutEvent</a></b> (<i>self</i>, QFocusEvent <i>event</i>)</li><li><div class="fn" />QFont <b><a href="qgraphicsscene.html#font">font</a></b> (<i>self</i>)</li><li><div class="fn" />QBrush <b><a href="qgraphicsscene.html#foregroundBrush">foregroundBrush</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qgraphicsscene.html#hasFocus">hasFocus</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qgraphicsscene.html#height">height</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#helpEvent">helpEvent</a></b> (<i>self</i>, QGraphicsSceneHelpEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#inputMethodEvent">inputMethodEvent</a></b> (<i>self</i>, QInputMethodEvent <i>event</i>)</li><li><div class="fn" />QVariant <b><a href="qgraphicsscene.html#inputMethodQuery">inputMethodQuery</a></b> (<i>self</i>, Qt.InputMethodQuery <i>query</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#invalidate">invalidate</a></b> (<i>self</i>, QRectF <i>rect</i> = QRectF(), SceneLayers <i>layers</i> = QGraphicsScene.AllLayers)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#invalidate-2">invalidate</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, SceneLayers <i>layers</i> = QGraphicsScene.AllLayers)</li><li><div class="fn" />bool <b><a href="qgraphicsscene.html#isActive">isActive</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qgraphicsscene.html#isSortCacheEnabled">isSortCacheEnabled</a></b> (<i>self</i>)</li><li><div class="fn" />QGraphicsItem <b><a href="qgraphicsscene.html#itemAt">itemAt</a></b> (<i>self</i>, QPointF <i>pos</i>)</li><li><div class="fn" />QGraphicsItem <b><a href="qgraphicsscene.html#itemAt-2">itemAt</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>)</li><li><div class="fn" />QGraphicsItem <b><a href="qgraphicsscene.html#itemAt-3">itemAt</a></b> (<i>self</i>, QPointF <i>pos</i>, QTransform <i>deviceTransform</i>)</li><li><div class="fn" />QGraphicsItem <b><a href="qgraphicsscene.html#itemAt-4">itemAt</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, QTransform <i>deviceTransform</i>)</li><li><div class="fn" />ItemIndexMethod <b><a href="qgraphicsscene.html#itemIndexMethod">itemIndexMethod</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#items">items</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#items-2">items</a></b> (<i>self</i>, Qt.SortOrder <i>order</i>)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#items-3">items</a></b> (<i>self</i>, QPointF <i>pos</i>)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#items-4">items</a></b> (<i>self</i>, QPointF <i>pos</i>, Qt.ItemSelectionMode <i>mode</i>, Qt.SortOrder <i>order</i>, QTransform <i>deviceTransform</i> = QTransform())</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#items-5">items</a></b> (<i>self</i>, QRectF <i>rectangle</i>, Qt.ItemSelectionMode <i>mode</i> = Qt.IntersectsItemShape)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#items-6">items</a></b> (<i>self</i>, QRectF <i>rect</i>, Qt.ItemSelectionMode <i>mode</i>, Qt.SortOrder <i>order</i>, QTransform <i>deviceTransform</i> = QTransform())</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#items-7">items</a></b> (<i>self</i>, QPolygonF <i>polygon</i>, Qt.ItemSelectionMode <i>mode</i> = Qt.IntersectsItemShape)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#items-8">items</a></b> (<i>self</i>, QPolygonF <i>polygon</i>, Qt.ItemSelectionMode <i>mode</i>, Qt.SortOrder <i>order</i>, QTransform <i>deviceTransform</i> = QTransform())</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#items-9">items</a></b> (<i>self</i>, QPainterPath <i>path</i>, Qt.ItemSelectionMode <i>mode</i> = Qt.IntersectsItemShape)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#items-10">items</a></b> (<i>self</i>, QPainterPath <i>path</i>, Qt.ItemSelectionMode <i>mode</i>, Qt.SortOrder <i>order</i>, QTransform <i>deviceTransform</i> = QTransform())</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#items-11">items</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, Qt.ItemSelectionMode <i>mode</i> = Qt.IntersectsItemShape)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#items-12">items</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, Qt.ItemSelectionMode <i>mode</i>, Qt.SortOrder <i>order</i>, QTransform <i>deviceTransform</i> = QTransform())</li><li><div class="fn" />QRectF <b><a href="qgraphicsscene.html#itemsBoundingRect">itemsBoundingRect</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#keyPressEvent">keyPressEvent</a></b> (<i>self</i>, QKeyEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#keyReleaseEvent">keyReleaseEvent</a></b> (<i>self</i>, QKeyEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#mouseDoubleClickEvent">mouseDoubleClickEvent</a></b> (<i>self</i>, QGraphicsSceneMouseEvent <i>event</i>)</li><li><div class="fn" />QGraphicsItem <b><a href="qgraphicsscene.html#mouseGrabberItem">mouseGrabberItem</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#mouseMoveEvent">mouseMoveEvent</a></b> (<i>self</i>, QGraphicsSceneMouseEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#mousePressEvent">mousePressEvent</a></b> (<i>self</i>, QGraphicsSceneMouseEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#mouseReleaseEvent">mouseReleaseEvent</a></b> (<i>self</i>, QGraphicsSceneMouseEvent <i>event</i>)</li><li><div class="fn" />QPalette <b><a href="qgraphicsscene.html#palette">palette</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#removeItem">removeItem</a></b> (<i>self</i>, QGraphicsItem <i>item</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#render">render</a></b> (<i>self</i>, QPainter <i>painter</i>, QRectF <i>target</i> = QRectF(), QRectF <i>source</i> = QRectF(), Qt.AspectRatioMode <i>mode</i> = Qt.KeepAspectRatio)</li><li><div class="fn" />QRectF <b><a href="qgraphicsscene.html#sceneRect">sceneRect</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsscene.html#selectedItems">selectedItems</a></b> (<i>self</i>)</li><li><div class="fn" />QPainterPath <b><a href="qgraphicsscene.html#selectionArea">selectionArea</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qgraphicsscene.html#sendEvent">sendEvent</a></b> (<i>self</i>, QGraphicsItem <i>item</i>, QEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setActivePanel">setActivePanel</a></b> (<i>self</i>, QGraphicsItem <i>item</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setActiveWindow">setActiveWindow</a></b> (<i>self</i>, QGraphicsWidget <i>widget</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setBackgroundBrush">setBackgroundBrush</a></b> (<i>self</i>, QBrush <i>brush</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setBspTreeDepth">setBspTreeDepth</a></b> (<i>self</i>, int <i>depth</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setFocus">setFocus</a></b> (<i>self</i>, Qt.FocusReason <i>focusReason</i> = Qt.OtherFocusReason)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setFocusItem">setFocusItem</a></b> (<i>self</i>, QGraphicsItem <i>item</i>, Qt.FocusReason <i>focusReason</i> = Qt.OtherFocusReason)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setFont">setFont</a></b> (<i>self</i>, QFont <i>font</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setForegroundBrush">setForegroundBrush</a></b> (<i>self</i>, QBrush <i>brush</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setItemIndexMethod">setItemIndexMethod</a></b> (<i>self</i>, ItemIndexMethod <i>method</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setPalette">setPalette</a></b> (<i>self</i>, QPalette <i>palette</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setSceneRect">setSceneRect</a></b> (<i>self</i>, QRectF <i>rect</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setSceneRect-2">setSceneRect</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a></b> (<i>self</i>, QPainterPath <i>path</i>, QTransform <i>deviceTransform</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setSelectionArea-2">setSelectionArea</a></b> (<i>self</i>, QPainterPath <i>path</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setSelectionArea-3">setSelectionArea</a></b> (<i>self</i>, QPainterPath <i>path</i>, Qt.ItemSelectionMode)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setSelectionArea-4">setSelectionArea</a></b> (<i>self</i>, QPainterPath <i>path</i>, Qt.ItemSelectionMode <i>mode</i>, QTransform <i>deviceTransform</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setSortCacheEnabled">setSortCacheEnabled</a></b> (<i>self</i>, bool <i>enabled</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setStickyFocus">setStickyFocus</a></b> (<i>self</i>, bool <i>enabled</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#setStyle">setStyle</a></b> (<i>self</i>, QStyle <i>style</i>)</li><li><div class="fn" />bool <b><a href="qgraphicsscene.html#stickyFocus">stickyFocus</a></b> (<i>self</i>)</li><li><div class="fn" />QStyle <b><a href="qgraphicsscene.html#style">style</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#update">update</a></b> (<i>self</i>, QRectF <i>rect</i> = QRectF())</li><li><div class="fn" /><b><a href="qgraphicsscene.html#update-2">update</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>)</li><li><div class="fn" />list-of-QGraphicsView <b><a href="qgraphicsscene.html#views">views</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsscene.html#wheelEvent">wheelEvent</a></b> (<i>self</i>, QGraphicsSceneWheelEvent <i>event</i>)</li><li><div class="fn" />float <b><a href="qgraphicsscene.html#width">width</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qgraphicsscene.html#changed">changed</a></b> (const QList<QRectF>&)</li><li><div class="fn" />void <b><a href="qgraphicsscene.html#sceneRectChanged">sceneRectChanged</a></b> (const QRectF&)</li><li><div class="fn" />void <b><a href="qgraphicsscene.html#selectionChanged">selectionChanged</a></b> ()</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.</p> <p>The class serves as a container for QGraphicsItems. It is used together with <a href="qgraphicsview.html">QGraphicsView</a> for visualizing graphical items, such as lines, rectangles, text, or even custom items, on a 2D surface. QGraphicsScene is part of the <a href="graphicsview.html">Graphics View Framework</a>.</p> <p>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 <a href="qgraphicsview.html">QGraphicsView</a> widget, you can either visualize the whole scene, or zoom in and view only parts of the scene.</p> <p>Example:</p> <pre class="cpp"> <span class="type">QGraphicsScene</span> scene; scene<span class="operator">.</span><a href="qgraphicsscene.html#addText">addText</a>(<span class="string">"Hello, world!"</span>); <span class="type"><a href="qgraphicsview.html">QGraphicsView</a></span> view(<span class="operator">&</span>scene); view<span class="operator">.</span>show(); </pre> <p>Note that QGraphicsScene has no visual appearance of its own; it only manages the items. You need to create a <a href="qgraphicsview.html">QGraphicsView</a> widget to visualize the scene.</p> <p>To add items to a scene, you start off by constructing a QGraphicsScene object. Then, you have two options: either add your existing <a href="qgraphicsitem.html">QGraphicsItem</a> objects by calling <a href="qgraphicsscene.html#addItem">addItem</a>(), or you can call one of the convenience functions <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPath">addPath</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addPolygon">addPolygon</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), or <a href="qgraphicsscene.html#addText">addText</a>(), 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.</p> <p>You can then visualize the scene using <a href="qgraphicsview.html">QGraphicsView</a>. When the scene changes, (e.g., when an item moves or is transformed) QGraphicsScene emits the <a href="qgraphicsscene.html#changed">changed</a>() signal. To remove an item, call <a href="qgraphicsscene.html#removeItem">removeItem</a>().</p> <p>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 <a href="qgraphicsscene.html#itemIndexMethod-prop">setItemIndexMethod</a>(). For more information about the available indexing algorithms, see the <a href="qgraphicsscene.html#itemIndexMethod-prop">itemIndexMethod</a> property.</p> <p>The scene's bounding rect is set by calling <a href="qgraphicsscene.html#sceneRect-prop">setSceneRect</a>(). 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 <a href="qgraphicsscene.html#itemsBoundingRect">itemsBoundingRect</a>(), as the scene rect. However, <a href="qgraphicsscene.html#itemsBoundingRect">itemsBoundingRect</a>() 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.</p> <p>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 <a href="qgraphicsscene.html#items">items</a>() functions can determine the location of an item within few milliseconds. There are several overloads to <a href="qgraphicsscene.html#items">items</a>(): 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 <a href="qgraphicsscene.html#itemAt">itemAt</a>() function that returns the topmost item at a given position.</p> <p>QGraphicsScene maintains selection information for the scene. To select items, call <a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a>(), and to clear the current selection, call <a href="qgraphicsscene.html#clearSelection">clearSelection</a>(). Call <a href="qgraphicsscene.html#selectedItems">selectedItems</a>() to get the list of all selected items.</p> <a id="event-handling-and-propagation" name="event-handling-and-propagation" /> <h3>Event Handling and Propagation</h3> <p>Another responsibility that QGraphicsScene has, is to propagate events from <a href="qgraphicsview.html">QGraphicsView</a>. To send an event to a scene, you construct an event that inherits <a href="qevent.html">QEvent</a>, and then send it using, for example, <a href="qcoreapplication.html#sendEvent">QApplication.sendEvent</a>(). <a href="qgraphicsscene.html#event">event</a>() 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 <a href="qgraphicsscene.html#keyPressEvent">keyPressEvent</a>(), and mouse press events are handled by <a href="qgraphicsscene.html#mousePressEvent">mousePressEvent</a>().</p> <p>Key events are delivered to the <i>focus item</i>. To set the focus item, you can either call <a href="qgraphicsscene.html#setFocusItem">setFocusItem</a>(), passing an item that accepts focus, or the item itself can call <a href="qgraphicsitem.html#setFocus">QGraphicsItem.setFocus</a>(). Call <a href="qgraphicsscene.html#focusItem">focusItem</a>() 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 <a href="qgraphicsscene.html#setFocus">setFocus</a>() is called, or if an item on the scene gains focus, the scene automatically gains focus. If the scene has focus, <a href="qgraphicsscene.html#hasFocus">hasFocus</a>() will return true, and key events will be forwarded to the focus item, if any. If the scene loses focus, (i.e., someone calls <a href="qgraphicsscene.html#clearFocus">clearFocus</a>()) 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.</p> <p>For mouse-over effects, QGraphicsScene dispatches <i>hover events</i>. If an item accepts hover events (see <a href="qgraphicsitem.html#acceptHoverEvents">QGraphicsItem.acceptHoverEvents</a>()), it will receive a <a href="qevent.html#Type-enum">GraphicsSceneHoverEnter</a> event when the mouse enters its area. As the mouse continues moving inside the item's area, QGraphicsScene will send it <a href="qevent.html#Type-enum">GraphicsSceneHoverMove</a> events. When the mouse leaves the item's area, the item will receive a <a href="qevent.html#Type-enum">GraphicsSceneHoverLeave</a> event.</p> <p>All mouse events are delivered to the current <i>mouse grabber</i> item. An item becomes the scene's mouse grabber if it accepts mouse events (see <a href="qgraphicsitem.html#acceptedMouseButtons">QGraphicsItem.acceptedMouseButtons</a>()) 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 <a href="qgraphicsscene.html#mouseGrabberItem">mouseGrabberItem</a>() to determine what item is currently grabbing the mouse.</p> <hr /><h2>Type Documentation</h2><h3 class="fn"><a name="ItemIndexMethod-enum" />QGraphicsScene.ItemIndexMethod</h3><p>This enum describes the indexing algorithms <a href="qgraphicsscene.html">QGraphicsScene</a> provides for managing positional information about items on the scene.</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QGraphicsScene.BspTreeIndex</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">A Binary Space Partitioning tree is applied. All <a href="qgraphicsscene.html">QGraphicsScene</a>'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).</td> </tr> <tr> <td class="topAlign"><tt>QGraphicsScene.NoIndex</tt></td> <td class="topAlign"><tt>-1</tt></td> <td class="topAlign">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.</td> </tr> </table> <p><b>See also</b> <a href="qgraphicsscene.html#itemIndexMethod-prop">setItemIndexMethod</a>() and <a href="qgraphicsscene.html#bspTreeDepth-prop">bspTreeDepth</a>.</p> <h3 class="fn"><a name="SceneLayer-enum" />QGraphicsScene.SceneLayer</h3><p>This enum describes the rendering layers in a <a href="qgraphicsscene.html">QGraphicsScene</a>. When <a href="qgraphicsscene.html">QGraphicsScene</a> draws the scene contents, it renders each of these layers separately, in order.</p> <p>Each layer represents a flag that can be OR'ed together when calling functions such as <a href="qgraphicsscene.html#invalidate">invalidate</a>() or <a href="qgraphicsview.html#invalidateScene">QGraphicsView.invalidateScene</a>().</p> <table class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QGraphicsScene.ItemLayer</tt></td> <td class="topAlign"><tt>0x1</tt></td> <td class="topAlign">The item layer. <a href="qgraphicsscene.html">QGraphicsScene</a> renders all items are in this layer by calling the virtual function <a class="obsolete" href="qgraphicsscene-obsolete.html#drawItems">drawItems</a>(). The item layer is drawn after the background layer, but before the foreground layer.</td> </tr> <tr> <td class="topAlign"><tt>QGraphicsScene.BackgroundLayer</tt></td> <td class="topAlign"><tt>0x2</tt></td> <td class="topAlign">The background layer. <a href="qgraphicsscene.html">QGraphicsScene</a> renders the scene's background in this layer by calling the virtual function <a href="qgraphicsscene.html#drawBackground">drawBackground</a>(). The background layer is drawn first of all layers.</td> </tr> <tr> <td class="topAlign"><tt>QGraphicsScene.ForegroundLayer</tt></td> <td class="topAlign"><tt>0x4</tt></td> <td class="topAlign">The foreground layer. <a href="qgraphicsscene.html">QGraphicsScene</a> renders the scene's foreground in this layer by calling the virtual function <a href="qgraphicsscene.html#drawForeground">drawForeground</a>(). The foreground layer is drawn last of all layers.</td> </tr> <tr> <td class="topAlign"><tt>QGraphicsScene.AllLayers</tt></td> <td class="topAlign"><tt>0xffff</tt></td> <td class="topAlign">All layers; this value represents a combination of all three layers.</td> </tr> </table> <p>This enum was introduced or modified in Qt 4.3.</p> <p>The SceneLayers type is a typedef for <a href="qflags.html">QFlags</a><SceneLayer>. It stores an OR combination of SceneLayer values.</p> <p><b>See also</b> <a href="qgraphicsscene.html#invalidate">invalidate</a>() and <a href="qgraphicsview.html#invalidateScene">QGraphicsView.invalidateScene</a>().</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QGraphicsScene" />QGraphicsScene.__init__ (<i>self</i>, <a href="qobject.html">QObject</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qgraphicsscene.html">QGraphicsScene</a> object. The <i>parent</i> parameter is passed to <a href="qobject.html">QObject</a>'s constructor.</p> <h3 class="fn"><a name="QGraphicsScene-2" />QGraphicsScene.__init__ (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>sceneRect</i>, <a href="qobject.html">QObject</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qgraphicsscene.html">QGraphicsScene</a> object, using <i>sceneRect</i> for its scene rectangle. The <i>parent</i> parameter is passed to <a href="qobject.html">QObject</a>'s constructor.</p> <p><b>See also</b> <a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a>.</p> <h3 class="fn"><a name="QGraphicsScene-3" />QGraphicsScene.__init__ (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>width</i>, float <i>height</i>, <a href="qobject.html">QObject</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qgraphicsscene.html">QGraphicsScene</a> object, using the rectangle specified by (<i>x</i>, <i>y</i>), and the given <i>width</i> and <i>height</i> for its scene rectangle. The <i>parent</i> parameter is passed to <a href="qobject.html">QObject</a>'s constructor.</p> <p><b>See also</b> <a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a>.</p> <h3 class="fn"><a name="activePanel" /><a href="qgraphicsitem.html">QGraphicsItem</a> QGraphicsScene.activePanel (<i>self</i>)</h3><p>Returns the current active panel, or 0 if no panel is currently active.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qgraphicsscene.html#setActivePanel">QGraphicsScene.setActivePanel</a>().</p> <h3 class="fn"><a name="activeWindow" /><a href="qgraphicswidget.html">QGraphicsWidget</a> QGraphicsScene.activeWindow (<i>self</i>)</h3><p>Returns the current active window, or 0 if no window is currently active.</p> <p>This function was introduced in Qt 4.4.</p> <p><b>See also</b> <a href="qgraphicsscene.html#setActiveWindow">QGraphicsScene.setActiveWindow</a>().</p> <h3 class="fn"><a name="addEllipse" /><a href="qgraphicsellipseitem.html">QGraphicsEllipseItem</a> QGraphicsScene.addEllipse (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>, <a href="qpen.html">QPen</a> <i>pen</i> = QPen(), <a href="qbrush.html">QBrush</a> <i>brush</i> = QBrush())</h3><p>Creates and adds an ellipse item to the scene, and returns the item pointer. The geometry of the ellipse is defined by <i>rect</i>, and its pen and brush are initialized to <i>pen</i> and <i>brush</i>.</p> <p>Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).</p> <p>If the item is visible (i.e., <a href="qgraphicsitem.html#isVisible">QGraphicsItem.isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p> <p><b>See also</b> <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPath">addPath</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), <a href="qgraphicsscene.html#addItem">addItem</a>(), and <a href="qgraphicsscene.html#addWidget">addWidget</a>().</p> <h3 class="fn"><a name="addEllipse-2" /><a href="qgraphicsellipseitem.html">QGraphicsEllipseItem</a> QGraphicsScene.addEllipse (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, <a href="qpen.html">QPen</a> <i>pen</i> = QPen(), <a href="qbrush.html">QBrush</a> <i>brush</i> = QBrush())</h3><p>This convenience function is equivalent to calling addEllipse(<a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>), <i>pen</i>, <i>brush</i>).</p> <p>This function was introduced in Qt 4.3.</p> <h3 class="fn"><a name="addItem" />QGraphicsScene.addItem (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a> <i>item</i>)</h3><p>The <i>item</i> argument has it's ownership transferred to Qt.</p><p>Adds or moves the <i>item</i> and all its childen to this scene. This scene takes ownership of the <i>item</i>.</p> <p>If the item is visible (i.e., <a href="qgraphicsitem.html#isVisible">QGraphicsItem.isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p> <p>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.</p> <p><a href="qgraphicsscene.html">QGraphicsScene</a> will send ItemSceneChange notifications to <i>item</i> 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), <a href="qgraphicsscene.html">QGraphicsScene</a> will send an addition notification as the item is removed from its previous scene.</p> <p>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.</p> <p><b>See also</b> <a href="qgraphicsscene.html#removeItem">removeItem</a>(), <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPath">addPath</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), <a href="qgraphicsscene.html#addWidget">addWidget</a>(), and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p> <h3 class="fn"><a name="addLine" /><a href="qgraphicslineitem.html">QGraphicsLineItem</a> QGraphicsScene.addLine (<i>self</i>, <a href="qlinef.html">QLineF</a> <i>line</i>, <a href="qpen.html">QPen</a> <i>pen</i> = QPen())</h3><p>Creates and adds a line item to the scene, and returns the item pointer. The geometry of the line is defined by <i>line</i>, and its pen is initialized to <i>pen</i>.</p> <p>Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).</p> <p>If the item is visible (i.e., <a href="qgraphicsitem.html#isVisible">QGraphicsItem.isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p> <p><b>See also</b> <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addPath">addPath</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), <a href="qgraphicsscene.html#addItem">addItem</a>(), and <a href="qgraphicsscene.html#addWidget">addWidget</a>().</p> <h3 class="fn"><a name="addLine-2" /><a href="qgraphicslineitem.html">QGraphicsLineItem</a> QGraphicsScene.addLine (<i>self</i>, float <i>x1</i>, float <i>y1</i>, float <i>x2</i>, float <i>y2</i>, <a href="qpen.html">QPen</a> <i>pen</i> = QPen())</h3><p>This convenience function is equivalent to calling addLine(<a href="qlinef.html">QLineF</a>(<i>x1</i>, <i>y1</i>, <i>x2</i>, <i>y2</i>), <i>pen</i>).</p> <p>This function was introduced in Qt 4.3.</p> <h3 class="fn"><a name="addPath" /><a href="qgraphicspathitem.html">QGraphicsPathItem</a> QGraphicsScene.addPath (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>path</i>, <a href="qpen.html">QPen</a> <i>pen</i> = QPen(), <a href="qbrush.html">QBrush</a> <i>brush</i> = QBrush())</h3><p>Creates and adds a path item to the scene, and returns the item pointer. The geometry of the path is defined by <i>path</i>, and its pen and brush are initialized to <i>pen</i> and <i>brush</i>.</p> <p>Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).</p> <p>If the item is visible (i.e., <a href="qgraphicsitem.html#isVisible">QGraphicsItem.isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p> <p><b>See also</b> <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), <a href="qgraphicsscene.html#addItem">addItem</a>(), and <a href="qgraphicsscene.html#addWidget">addWidget</a>().</p> <h3 class="fn"><a name="addPixmap" /><a href="qgraphicspixmapitem.html">QGraphicsPixmapItem</a> QGraphicsScene.addPixmap (<i>self</i>, <a href="qpixmap.html">QPixmap</a> <i>pixmap</i>)</h3><p>Creates and adds a pixmap item to the scene, and returns the item pointer. The pixmap is defined by <i>pixmap</i>.</p> <p>Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).</p> <p>If the item is visible (i.e., <a href="qgraphicsitem.html#isVisible">QGraphicsItem.isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p> <p><b>See also</b> <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPath">addPath</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), <a href="qgraphicsscene.html#addItem">addItem</a>(), and <a href="qgraphicsscene.html#addWidget">addWidget</a>().</p> <h3 class="fn"><a name="addPolygon" /><a href="qgraphicspolygonitem.html">QGraphicsPolygonItem</a> QGraphicsScene.addPolygon (<i>self</i>, <a href="qpolygonf.html">QPolygonF</a> <i>polygon</i>, <a href="qpen.html">QPen</a> <i>pen</i> = QPen(), <a href="qbrush.html">QBrush</a> <i>brush</i> = QBrush())</h3><p>Creates and adds a polygon item to the scene, and returns the item pointer. The polygon is defined by <i>polygon</i>, and its pen and brush are initialized to <i>pen</i> and <i>brush</i>.</p> <p>Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0).</p> <p>If the item is visible (i.e., <a href="qgraphicsitem.html#isVisible">QGraphicsItem.isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p> <p><b>See also</b> <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPath">addPath</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), <a href="qgraphicsscene.html#addItem">addItem</a>(), and <a href="qgraphicsscene.html#addWidget">addWidget</a>().</p> <h3 class="fn"><a name="addRect" /><a href="qgraphicsrectitem.html">QGraphicsRectItem</a> QGraphicsScene.addRect (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>, <a href="qpen.html">QPen</a> <i>pen</i> = QPen(), <a href="qbrush.html">QBrush</a> <i>brush</i> = QBrush())</h3><p>Creates and adds a rectangle item to the scene, and returns the item pointer. The geometry of the rectangle is defined by <i>rect</i>, and its pen and brush are initialized to <i>pen</i> and <i>brush</i>.</p> <p>Note that the item's geometry is provided in item coordinates, and its position is initialized to (0, 0). For example, if a <a href="qrect.html">QRect</a>(50, 50, 100, 100) is added, its top-left corner will be at (50, 50) relative to the origin in the items coordinate system.</p> <p>If the item is visible (i.e., <a href="qgraphicsitem.html#isVisible">QGraphicsItem.isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p> <p><b>See also</b> <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), <a href="qgraphicsscene.html#addItem">addItem</a>(), and <a href="qgraphicsscene.html#addWidget">addWidget</a>().</p> <h3 class="fn"><a name="addRect-2" /><a href="qgraphicsrectitem.html">QGraphicsRectItem</a> QGraphicsScene.addRect (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, <a href="qpen.html">QPen</a> <i>pen</i> = QPen(), <a href="qbrush.html">QBrush</a> <i>brush</i> = QBrush())</h3><p>This convenience function is equivalent to calling addRect(<a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>), <i>pen</i>, <i>brush</i>).</p> <p>This function was introduced in Qt 4.3.</p> <h3 class="fn"><a name="addSimpleText" /><a href="qgraphicssimpletextitem.html">QGraphicsSimpleTextItem</a> QGraphicsScene.addSimpleText (<i>self</i>, QString <i>text</i>, <a href="qfont.html">QFont</a> <i>font</i> = QFont())</h3><p>Creates and adds a <a href="qgraphicssimpletextitem.html">QGraphicsSimpleTextItem</a> to the scene, and returns the item pointer. The text string is initialized to <i>text</i>, and its font is initialized to <i>font</i>.</p> <p>The item's position is initialized to (0, 0).</p> <p>If the item is visible (i.e., <a href="qgraphicsitem.html#isVisible">QGraphicsItem.isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p> <p><b>See also</b> <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addItem">addItem</a>(), and <a href="qgraphicsscene.html#addWidget">addWidget</a>().</p> <h3 class="fn"><a name="addText" /><a href="qgraphicstextitem.html">QGraphicsTextItem</a> QGraphicsScene.addText (<i>self</i>, QString <i>text</i>, <a href="qfont.html">QFont</a> <i>font</i> = QFont())</h3><p>Creates and adds a text item to the scene, and returns the item pointer. The text string is initialized to <i>text</i>, and its font is initialized to <i>font</i>.</p> <p>The item's position is initialized to (0, 0).</p> <p>If the item is visible (i.e., <a href="qgraphicsitem.html#isVisible">QGraphicsItem.isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p> <p><b>See also</b> <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addItem">addItem</a>(), and <a href="qgraphicsscene.html#addWidget">addWidget</a>().</p> <h3 class="fn"><a name="addWidget" /><a href="qgraphicsproxywidget.html">QGraphicsProxyWidget</a> QGraphicsScene.addWidget (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>widget</i>, <a href="qt-windowflags.html">Qt.WindowFlags</a> <i>flags</i> = 0)</h3><p>The <i>widget</i> argument has it's ownership transferred to Qt.</p><p>Creates a new <a href="qgraphicsproxywidget.html">QGraphicsProxyWidget</a> for <i>widget</i>, adds it to the scene, and returns a pointer to the proxy. <i>wFlags</i> set the default window flags for the embedding proxy widget.</p> <p>The item's position is initialized to (0, 0).</p> <p>If the item is visible (i.e., <a href="qgraphicsitem.html#isVisible">QGraphicsItem.isVisible</a>() returns true), <a href="qgraphicsscene.html">QGraphicsScene</a> will emit <a href="qgraphicsscene.html#changed">changed</a>() once control goes back to the event loop.</p> <p>Note that widgets with the <a href="qt.html#WidgetAttribute-enum">Qt.WA_PaintOnScreen</a> widget attribute set and widgets that wrap an external application or controller are not supported. Examples are <a href="qglwidget.html">QGLWidget</a> and <a href="qaxwidget.html">QAxWidget</a>.</p> <p><b>See also</b> <a href="qgraphicsscene.html#addEllipse">addEllipse</a>(), <a href="qgraphicsscene.html#addLine">addLine</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addPixmap">addPixmap</a>(), <a href="qgraphicsscene.html#addRect">addRect</a>(), <a href="qgraphicsscene.html#addText">addText</a>(), <a href="qgraphicsscene.html#addSimpleText">addSimpleText</a>(), and <a href="qgraphicsscene.html#addItem">addItem</a>().</p> <h3 class="fn"><a name="advance" />QGraphicsScene.advance (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void advance()</tt>.</p><p>This slot <i>advances</i> the scene by one step, by calling <a href="qgraphicsitem.html#advance">QGraphicsItem.advance</a>() 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, <a href="qgraphicsitem.html#advance">QGraphicsItem.advance</a>() is called passing a value of 0 as an argument, and 1 is passed in the second phase.</p> <p><b>See also</b> <a href="qgraphicsitem.html#advance">QGraphicsItem.advance</a>(), <a href="qgraphicsitemanimation.html">QGraphicsItemAnimation</a>, and <a href="qtimeline.html">QTimeLine</a>.</p> <h3 class="fn"><a name="backgroundBrush" /><a href="qbrush.html">QBrush</a> QGraphicsScene.backgroundBrush (<i>self</i>)</h3><h3 class="fn"><a name="bspTreeDepth" />int QGraphicsScene.bspTreeDepth (<i>self</i>)</h3><h3 class="fn"><a name="clear" />QGraphicsScene.clear (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void clear()</tt>.</p><p>Removes and deletes all items from the scene, but otherwise leaves the state of the scene unchanged.</p> <p>This function was introduced in Qt 4.4.</p> <p><b>See also</b> <a href="qgraphicsscene.html#addItem">addItem</a>().</p> <h3 class="fn"><a name="clearFocus" />QGraphicsScene.clearFocus (<i>self</i>)</h3><p>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.</p> <p>A scene that does not have focus ignores key events.</p> <p><b>See also</b> <a href="qgraphicsscene.html#hasFocus">hasFocus</a>(), <a href="qgraphicsscene.html#setFocus">setFocus</a>(), and <a href="qgraphicsscene.html#setFocusItem">setFocusItem</a>().</p> <h3 class="fn"><a name="clearSelection" />QGraphicsScene.clearSelection (<i>self</i>)</h3><p>Clears the current selection.</p> <p><b>See also</b> <a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a>() and <a href="qgraphicsscene.html#selectedItems">selectedItems</a>().</p> <h3 class="fn"><a name="collidingItems" />list-of-QGraphicsItem QGraphicsScene.collidingItems (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a> <i>item</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i> = Qt.IntersectsItemShape)</h3><p>Returns a list of all items that collide with <i>item</i>. Collisions are determined by calling <a href="qgraphicsitem.html#collidesWithItem">QGraphicsItem.collidesWithItem</a>(); the collision detection is determined by <i>mode</i>. By default, all items whose shape intersects <i>item</i> or is contained inside <i>item</i>'s shape are returned.</p> <p>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).</p> <p><b>See also</b> <a href="qgraphicsscene.html#items">items</a>(), <a href="qgraphicsscene.html#itemAt">itemAt</a>(), <a href="qgraphicsitem.html#collidesWithItem">QGraphicsItem.collidesWithItem</a>(), and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p> <h3 class="fn"><a name="contextMenuEvent" />QGraphicsScene.contextMenuEvent (<i>self</i>, <a href="qgraphicsscenecontextmenuevent.html">QGraphicsSceneContextMenuEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>contextMenuEvent</i>, 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.</p> <p><b>See also</b> <a href="qgraphicsitem.html#contextMenuEvent">QGraphicsItem.contextMenuEvent</a>().</p> <h3 class="fn"><a name="createItemGroup" /><a href="qgraphicsitemgroup.html">QGraphicsItemGroup</a> QGraphicsScene.createItemGroup (<i>self</i>, list-of-QGraphicsItem <i>items</i>)</h3><p>The <i>items</i> argument has it's ownership transferred to Qt.</p><p>Groups all items in <i>items</i> into a new <a href="qgraphicsitemgroup.html">QGraphicsItemGroup</a>, and returns a pointer to the group. The group is created with the common ancestor of <i>items</i> 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 <i>items</i> is empty, this function will return an empty top-level <a href="qgraphicsitemgroup.html">QGraphicsItemGroup</a>.</p> <p><a href="qgraphicsscene.html">QGraphicsScene</a> has ownership of the group item; you do not need to delete it. To dismantle (ungroup) a group, call <a href="qgraphicsscene.html#destroyItemGroup">destroyItemGroup</a>().</p> <p><b>See also</b> <a href="qgraphicsscene.html#destroyItemGroup">destroyItemGroup</a>() and <a href="qgraphicsitemgroup.html#addToGroup">QGraphicsItemGroup.addToGroup</a>().</p> <h3 class="fn"><a name="destroyItemGroup" />QGraphicsScene.destroyItemGroup (<i>self</i>, <a href="qgraphicsitemgroup.html">QGraphicsItemGroup</a> <i>group</i>)</h3><p>The <i>group</i> argument has it's ownership transferred to Qt.</p><p>Reparents all items in <i>group</i> to <i>group</i>'s parent item, then removes <i>group</i> from the scene, and finally deletes it. The items' positions and transformations are mapped from the group to the group's parent.</p> <p><b>See also</b> <a href="qgraphicsscene.html#createItemGroup">createItemGroup</a>() and <a href="qgraphicsitemgroup.html#removeFromGroup">QGraphicsItemGroup.removeFromGroup</a>().</p> <h3 class="fn"><a name="dragEnterEvent" />QGraphicsScene.dragEnterEvent (<i>self</i>, <a href="qgraphicsscenedragdropevent.html">QGraphicsSceneDragDropEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>event</i>, can be reimplemented in a subclass to receive drag enter events for the scene.</p> <p>The default implementation accepts the event and prepares the scene to accept drag move events.</p> <p><b>See also</b> <a href="qgraphicsitem.html#dragEnterEvent">QGraphicsItem.dragEnterEvent</a>(), <a href="qgraphicsscene.html#dragMoveEvent">dragMoveEvent</a>(), <a href="qgraphicsscene.html#dragLeaveEvent">dragLeaveEvent</a>(), and <a href="qgraphicsscene.html#dropEvent">dropEvent</a>().</p> <h3 class="fn"><a name="dragLeaveEvent" />QGraphicsScene.dragLeaveEvent (<i>self</i>, <a href="qgraphicsscenedragdropevent.html">QGraphicsSceneDragDropEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>event</i>, can be reimplemented in a subclass to receive drag leave events for the scene.</p> <p><b>See also</b> <a href="qgraphicsitem.html#dragLeaveEvent">QGraphicsItem.dragLeaveEvent</a>(), <a href="qgraphicsscene.html#dragEnterEvent">dragEnterEvent</a>(), <a href="qgraphicsscene.html#dragMoveEvent">dragMoveEvent</a>(), and <a href="qgraphicsscene.html#dropEvent">dropEvent</a>().</p> <h3 class="fn"><a name="dragMoveEvent" />QGraphicsScene.dragMoveEvent (<i>self</i>, <a href="qgraphicsscenedragdropevent.html">QGraphicsSceneDragDropEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>event</i>, can be reimplemented in a subclass to receive drag move events for the scene.</p> <p><b>See also</b> <a href="qgraphicsitem.html#dragMoveEvent">QGraphicsItem.dragMoveEvent</a>(), <a href="qgraphicsscene.html#dragEnterEvent">dragEnterEvent</a>(), <a href="qgraphicsscene.html#dragLeaveEvent">dragLeaveEvent</a>(), and <a href="qgraphicsscene.html#dropEvent">dropEvent</a>().</p> <h3 class="fn"><a name="drawBackground" />QGraphicsScene.drawBackground (<i>self</i>, <a href="qpainter.html">QPainter</a> <i>painter</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>)</h3><p>Draws the background of the scene using <i>painter</i>, before any items and the foreground are drawn. Reimplement this function to provide a custom background for the scene.</p> <p>All painting is done in <i>scene</i> coordinates. The <i>rect</i> parameter is the exposed rectangle.</p> <p>If all you want is to define a color, texture, or gradient for the background, you can call <a href="qgraphicsscene.html#backgroundBrush-prop">setBackgroundBrush</a>() instead.</p> <p><b>See also</b> <a href="qgraphicsscene.html#drawForeground">drawForeground</a>() and <a class="obsolete" href="qgraphicsscene-obsolete.html#drawItems">drawItems</a>().</p> <h3 class="fn"><a name="drawForeground" />QGraphicsScene.drawForeground (<i>self</i>, <a href="qpainter.html">QPainter</a> <i>painter</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>)</h3><p>Draws the foreground of the scene using <i>painter</i>, after the background and all items have been drawn. Reimplement this function to provide a custom foreground for the scene.</p> <p>All painting is done in <i>scene</i> coordinates. The <i>rect</i> parameter is the exposed rectangle.</p> <p>If all you want is to define a color, texture or gradient for the foreground, you can call <a href="qgraphicsscene.html#foregroundBrush-prop">setForegroundBrush</a>() instead.</p> <p><b>See also</b> <a href="qgraphicsscene.html#drawBackground">drawBackground</a>() and <a class="obsolete" href="qgraphicsscene-obsolete.html#drawItems">drawItems</a>().</p> <h3 class="fn"><a name="drawItems" />QGraphicsScene.drawItems (<i>self</i>, <a href="qpainter.html">QPainter</a> <i>painter</i>, list-of-QGraphicsItem <i>items</i>, list-of-QStyleOptionGraphicsItem <i>options</i>, <a href="qwidget.html">QWidget</a> <i>widget</i> = None)</h3><h3 class="fn"><a name="dropEvent" />QGraphicsScene.dropEvent (<i>self</i>, <a href="qgraphicsscenedragdropevent.html">QGraphicsSceneDragDropEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>event</i>, can be reimplemented in a subclass to receive drop events for the scene.</p> <p><b>See also</b> <a href="qgraphicsitem.html#dropEvent">QGraphicsItem.dropEvent</a>(), <a href="qgraphicsscene.html#dragEnterEvent">dragEnterEvent</a>(), <a href="qgraphicsscene.html#dragMoveEvent">dragMoveEvent</a>(), and <a href="qgraphicsscene.html#dragLeaveEvent">dragLeaveEvent</a>().</p> <h3 class="fn"><a name="event" />bool QGraphicsScene.event (<i>self</i>, <a href="qevent.html">QEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qobject.html#event">QObject.event</a>().</p> <p>Processes the event <i>event</i>, and dispatches it to the respective event handlers.</p> <p>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.</p> <p>Unlike <a href="qwidget.html">QWidget</a>, <a href="qgraphicsscene.html">QGraphicsScene</a> does not have the convenience functions <a href="qwidget.html#enterEvent">enterEvent()</a> and <a href="qwidget.html#leaveEvent">leaveEvent()</a>. Use this function to obtain those events instead.</p> <p><b>See also</b> <a href="qgraphicsscene.html#contextMenuEvent">contextMenuEvent</a>(), <a href="qgraphicsscene.html#keyPressEvent">keyPressEvent</a>(), <a href="qgraphicsscene.html#keyReleaseEvent">keyReleaseEvent</a>(), <a href="qgraphicsscene.html#mousePressEvent">mousePressEvent</a>(), <a href="qgraphicsscene.html#mouseMoveEvent">mouseMoveEvent</a>(), <a href="qgraphicsscene.html#mouseReleaseEvent">mouseReleaseEvent</a>(), <a href="qgraphicsscene.html#mouseDoubleClickEvent">mouseDoubleClickEvent</a>(), <a href="qgraphicsscene.html#focusInEvent">focusInEvent</a>(), and <a href="qgraphicsscene.html#focusOutEvent">focusOutEvent</a>().</p> <h3 class="fn"><a name="eventFilter" />bool QGraphicsScene.eventFilter (<i>self</i>, <a href="qobject.html">QObject</a> <i>watched</i>, <a href="qevent.html">QEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qobject.html#eventFilter">QObject.eventFilter</a>().</p> <p><a href="qgraphicsscene.html">QGraphicsScene</a> filters <a href="qapplication.html">QApplication</a>'s events to detect palette and font changes.</p> <h3 class="fn"><a name="focusInEvent" />QGraphicsScene.focusInEvent (<i>self</i>, <a href="qfocusevent.html">QFocusEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>focusEvent</i>, can be reimplemented in a subclass to receive focus in events.</p> <p>The default implementation sets focus on the scene, and then on the last focus item.</p> <p><b>See also</b> <a href="qgraphicsitem.html#focusOutEvent">QGraphicsItem.focusOutEvent</a>().</p> <h3 class="fn"><a name="focusItem" /><a href="qgraphicsitem.html">QGraphicsItem</a> QGraphicsScene.focusItem (<i>self</i>)</h3><p>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.</p> <p>The focus item receives keyboard input when the scene receives a key event.</p> <p><b>See also</b> <a href="qgraphicsscene.html#setFocusItem">setFocusItem</a>(), <a href="qgraphicsitem.html#hasFocus">QGraphicsItem.hasFocus</a>(), and <a href="qgraphicsscene.html#isActive">isActive</a>().</p> <h3 class="fn"><a name="focusNextPrevChild" />bool QGraphicsScene.focusNextPrevChild (<i>self</i>, bool <i>next</i>)</h3><p>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 <i>next</i> is true, this function searches forward; if <i>next</i> is false, it searches backward.</p> <p>You can reimplement this function in a subclass of <a href="qgraphicsscene.html">QGraphicsScene</a> 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 <a href="qgraphicswidget.html#setTabOrder">QGraphicsWidget.setTabOrder</a>().</p> <p>This function was introduced in Qt 4.4.</p> <h3 class="fn"><a name="focusOutEvent" />QGraphicsScene.focusOutEvent (<i>self</i>, <a href="qfocusevent.html">QFocusEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>focusEvent</i>, can be reimplemented in a subclass to receive focus out events.</p> <p>The default implementation removes focus from any focus item, then removes focus from the scene.</p> <p><b>See also</b> <a href="qgraphicsitem.html#focusInEvent">QGraphicsItem.focusInEvent</a>().</p> <h3 class="fn"><a name="font" /><a href="qfont.html">QFont</a> QGraphicsScene.font (<i>self</i>)</h3><h3 class="fn"><a name="foregroundBrush" /><a href="qbrush.html">QBrush</a> QGraphicsScene.foregroundBrush (<i>self</i>)</h3><h3 class="fn"><a name="hasFocus" />bool QGraphicsScene.hasFocus (<i>self</i>)</h3><p>Returns true if the scene has focus; otherwise returns false. If the scene has focus, it will will forward key events from <a href="qkeyevent.html">QKeyEvent</a> to any item that has focus.</p> <p><b>See also</b> <a href="qgraphicsscene.html#setFocus">setFocus</a>() and <a href="qgraphicsscene.html#setFocusItem">setFocusItem</a>().</p> <h3 class="fn"><a name="height" />float QGraphicsScene.height (<i>self</i>)</h3><p>This convenience function is equivalent to calling <tt>sceneRect().height()</tt>.</p> <p><b>See also</b> <a href="qgraphicsscene.html#width">width</a>().</p> <h3 class="fn"><a name="helpEvent" />QGraphicsScene.helpEvent (<i>self</i>, <a href="qgraphicsscenehelpevent.html">QGraphicsSceneHelpEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>helpEvent</i>, can be reimplemented in a subclass to receive help events. The events are of type <a href="qevent.html#Type-enum">QEvent.ToolTip</a>, which are created when a tooltip is requested.</p> <p>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.</p> <p><b>See also</b> <a href="qgraphicsitem.html#toolTip">QGraphicsItem.toolTip</a>() and <a href="qgraphicsscenehelpevent.html">QGraphicsSceneHelpEvent</a>.</p> <h3 class="fn"><a name="inputMethodEvent" />QGraphicsScene.inputMethodEvent (<i>self</i>, <a href="qinputmethodevent.html">QInputMethodEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>event</i>, can be reimplemented in a subclass to receive input method events for the scene.</p> <p>The default implementation forwards the event to the <a href="qgraphicsscene.html#focusItem">focusItem</a>(). If no item currently has focus or the current focus item does not accept input methods, this function does nothing.</p> <p><b>See also</b> <a href="qgraphicsitem.html#inputMethodEvent">QGraphicsItem.inputMethodEvent</a>().</p> <h3 class="fn"><a name="inputMethodQuery" />QVariant QGraphicsScene.inputMethodQuery (<i>self</i>, <a href="qt.html#InputMethodQuery-enum">Qt.InputMethodQuery</a> <i>query</i>)</h3><p>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.</p> <p>The <i>query</i> parameter specifies which property is queried.</p> <p><b>See also</b> <a href="qwidget.html#inputMethodQuery">QWidget.inputMethodQuery</a>().</p> <h3 class="fn"><a name="invalidate" />QGraphicsScene.invalidate (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i> = QRectF(), <a href="qgraphicsscene-scenelayers.html">SceneLayers</a> <i>layers</i> = QGraphicsScene.AllLayers)</h3><p>This method is also a Qt slot with the C++ signature <tt>void invalidate(const QRectF& = QRectF(),QGraphicsScene::SceneLayers = QGraphicsScene.AllLayers)</tt>.</p><p>Invalidates and schedules a redraw of the <i>layers</i> in <i>rect</i> on the scene. Any cached content in <i>layers</i> is unconditionally invalidated and redrawn.</p> <p>You can use this function overload to notify <a href="qgraphicsscene.html">QGraphicsScene</a> 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 <a href="qgraphicsview.html">QGraphicsView</a> has enabled <a href="qgraphicsview.html#CacheModeFlag-enum">CacheBackground</a>.</p> <p>Example:</p> <pre class="cpp"> <span class="type"><a href="qrectf.html">QRectF</a></span> TileScene<span class="operator">.</span>rectForTile(<span class="type">int</span> x<span class="operator">,</span> <span class="type">int</span> y) <span class="keyword">const</span> { <span class="comment">// Return the rectangle for the tile at position (x, y).</span> <span class="keyword">return</span> <span class="type"><a href="qrectf.html">QRectF</a></span>(x <span class="operator">*</span> tileWidth<span class="operator">,</span> y <span class="operator">*</span> tileHeight<span class="operator">,</span> tileWidth<span class="operator">,</span> tileHeight); } <span class="type">void</span> TileScene<span class="operator">.</span>setTile(<span class="type">int</span> x<span class="operator">,</span> <span class="type">int</span> y<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="qpixmap.html">QPixmap</a></span> <span class="operator">&</span>pixmap) { <span class="comment">// Sets or replaces the tile at position (x, y) with pixmap.</span> <span class="keyword">if</span> (x <span class="operator">></span><span class="operator">=</span> <span class="number">0</span> <span class="operator">&</span><span class="operator">&</span> x <span class="operator"><</span> numTilesH <span class="operator">&</span><span class="operator">&</span> y <span class="operator">></span><span class="operator">=</span> <span class="number">0</span> <span class="operator">&</span><span class="operator">&</span> y <span class="operator"><</span> numTilesV) { tiles<span class="operator">[</span>y<span class="operator">]</span><span class="operator">[</span>x<span class="operator">]</span> <span class="operator">=</span> pixmap; invalidate(rectForTile(x<span class="operator">,</span> y)<span class="operator">,</span> BackgroundLayer); } } <span class="type">void</span> TileScene<span class="operator">.</span>drawBackground(<span class="type"><a href="qpainter.html">QPainter</a></span> <span class="operator">*</span>painter<span class="operator">,</span> <span class="keyword">const</span> <span class="type"><a href="qrectf.html">QRectF</a></span> <span class="operator">&</span>exposed) { <span class="comment">// Draws all tiles that intersect the exposed area.</span> <span class="keyword">for</span> (<span class="type">int</span> y <span class="operator">=</span> <span class="number">0</span>; y <span class="operator"><</span> numTilesV; <span class="operator">+</span><span class="operator">+</span>y) { <span class="keyword">for</span> (<span class="type">int</span> x <span class="operator">=</span> <span class="number">0</span>; x <span class="operator"><</span> numTilesH; <span class="operator">+</span><span class="operator">+</span>x) { <span class="type"><a href="qrectf.html">QRectF</a></span> rect <span class="operator">=</span> rectForTile(x<span class="operator">,</span> y); <span class="keyword">if</span> (exposed<span class="operator">.</span>intersects(rect)) painter<span class="operator">-</span><span class="operator">></span>drawPixmap(rect<span class="operator">.</span>topLeft()<span class="operator">,</span> tiles<span class="operator">[</span>y<span class="operator">]</span><span class="operator">[</span>x<span class="operator">]</span>); } } } </pre> <p>Note that <a href="qgraphicsview.html">QGraphicsView</a> currently supports background caching only (see <a href="qgraphicsview.html#CacheModeFlag-enum">QGraphicsView.CacheBackground</a>). This function is equivalent to calling <a href="qgraphicsscene.html#update">update</a>() if any layer but <a href="qgraphicsscene.html#SceneLayer-enum">BackgroundLayer</a> is passed.</p> <p><b>See also</b> <a href="qgraphicsview.html#resetCachedContent">QGraphicsView.resetCachedContent</a>().</p> <h3 class="fn"><a name="invalidate-2" />QGraphicsScene.invalidate (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, <a href="qgraphicsscene-scenelayers.html">SceneLayers</a> <i>layers</i> = QGraphicsScene.AllLayers)</h3><p>This is an overloaded function.</p> <p>This convenience function is equivalent to calling invalidate(<a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>), <i>layers</i>);</p> <p>This function was introduced in Qt 4.3.</p> <h3 class="fn"><a name="isActive" />bool QGraphicsScene.isActive (<i>self</i>)</h3><p>Returns true if the scene is active (e.g., it's viewed by at least one <a href="qgraphicsview.html">QGraphicsView</a> that is active); otherwise returns false.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qgraphicsitem.html#isActive">QGraphicsItem.isActive</a>() and <a href="qwidget.html#isActiveWindow-prop">QWidget.isActiveWindow</a>().</p> <h3 class="fn"><a name="isSortCacheEnabled" />bool QGraphicsScene.isSortCacheEnabled (<i>self</i>)</h3><h3 class="fn"><a name="itemAt" /><a href="qgraphicsitem.html">QGraphicsItem</a> QGraphicsScene.itemAt (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>pos</i>)</h3><p>Returns the topmost visible item at the specified <i>position</i>, or 0 if there are no items at this position.</p> <p><i>deviceTransform</i> is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qgraphicsscene.html#items">items</a>(), <a href="qgraphicsscene.html#collidingItems">collidingItems</a>(), and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p> <h3 class="fn"><a name="itemAt-2" /><a href="qgraphicsitem.html">QGraphicsItem</a> QGraphicsScene.itemAt (<i>self</i>, float <i>x</i>, float <i>y</i>)</h3><h3 class="fn"><a name="itemAt-3" /><a href="qgraphicsitem.html">QGraphicsItem</a> QGraphicsScene.itemAt (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>pos</i>, <a href="qtransform.html">QTransform</a> <i>deviceTransform</i>)</h3><p>This is an overloaded function.</p> <p>Returns the topmost item at the position specified by (<i>x</i>, <i>y</i>), or 0 if there are no items at this position.</p> <p><i>deviceTransform</i> is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.</p> <p>This convenience function is equivalent to calling <tt>itemAt(QPointF(x, y), deviceTransform)</tt>.</p> <p>This function was introduced in Qt 4.6.</p> <h3 class="fn"><a name="itemAt-4" /><a href="qgraphicsitem.html">QGraphicsItem</a> QGraphicsScene.itemAt (<i>self</i>, float <i>x</i>, float <i>y</i>, <a href="qtransform.html">QTransform</a> <i>deviceTransform</i>)</h3><h3 class="fn"><a name="itemIndexMethod" /><a href="qgraphicsscene.html#ItemIndexMethod-enum">ItemIndexMethod</a> QGraphicsScene.itemIndexMethod (<i>self</i>)</h3><h3 class="fn"><a name="items" />list-of-QGraphicsItem QGraphicsScene.items (<i>self</i>)</h3><p>Returns a list of all items in the scene in descending stacking order.</p> <p><b>See also</b> <a href="qgraphicsscene.html#addItem">addItem</a>(), <a href="qgraphicsscene.html#removeItem">removeItem</a>(), and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p> <h3 class="fn"><a name="items-2" />list-of-QGraphicsItem QGraphicsScene.items (<i>self</i>, <a href="qt.html#SortOrder-enum">Qt.SortOrder</a> <i>order</i>)</h3><p>Returns an ordered list of all items on the scene. <i>order</i> decides the stacking order.</p> <p><b>See also</b> <a href="qgraphicsscene.html#addItem">addItem</a>(), <a href="qgraphicsscene.html#removeItem">removeItem</a>(), and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p> <h3 class="fn"><a name="items-3" />list-of-QGraphicsItem QGraphicsScene.items (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>pos</i>)</h3><p>Returns all visible items that, depending on <i>mode</i>, are at the specified <i>pos</i> in a list sorted using <i>order</i>.</p> <p>The default value for <i>mode</i> is <a href="qt.html#ItemSelectionMode-enum">Qt.IntersectsItemShape</a>; all items whose exact shape intersects with <i>pos</i> are returned.</p> <p><i>deviceTransform</i> is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qgraphicsscene.html#itemAt">itemAt</a>() and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p> <h3 class="fn"><a name="items-4" />list-of-QGraphicsItem QGraphicsScene.items (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>pos</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i>, <a href="qt.html#SortOrder-enum">Qt.SortOrder</a> <i>order</i>, <a href="qtransform.html">QTransform</a> <i>deviceTransform</i> = QTransform())</h3><h3 class="fn"><a name="items-5" />list-of-QGraphicsItem QGraphicsScene.items (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rectangle</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i> = Qt.IntersectsItemShape)</h3><h3 class="fn"><a name="items-6" />list-of-QGraphicsItem QGraphicsScene.items (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i>, <a href="qt.html#SortOrder-enum">Qt.SortOrder</a> <i>order</i>, <a href="qtransform.html">QTransform</a> <i>deviceTransform</i> = QTransform())</h3><h3 class="fn"><a name="items-7" />list-of-QGraphicsItem QGraphicsScene.items (<i>self</i>, <a href="qpolygonf.html">QPolygonF</a> <i>polygon</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i> = Qt.IntersectsItemShape)</h3><p>This is an overloaded function.</p> <p>Returns all visible items that, depending on <i>mode</i>, are either inside or intersect with the rectangle defined by <i>x</i>, <i>y</i>, <i>w</i> and <i>h</i>, in a list sorted using <i>order</i>.</p> <p><i>deviceTransform</i> is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.</p> <p>This function was introduced in Qt 4.6.</p> <h3 class="fn"><a name="items-8" />list-of-QGraphicsItem QGraphicsScene.items (<i>self</i>, <a href="qpolygonf.html">QPolygonF</a> <i>polygon</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i>, <a href="qt.html#SortOrder-enum">Qt.SortOrder</a> <i>order</i>, <a href="qtransform.html">QTransform</a> <i>deviceTransform</i> = QTransform())</h3><h3 class="fn"><a name="items-9" />list-of-QGraphicsItem QGraphicsScene.items (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>path</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i> = Qt.IntersectsItemShape)</h3><h3 class="fn"><a name="items-10" />list-of-QGraphicsItem QGraphicsScene.items (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>path</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i>, <a href="qt.html#SortOrder-enum">Qt.SortOrder</a> <i>order</i>, <a href="qtransform.html">QTransform</a> <i>deviceTransform</i> = QTransform())</h3><p>This is an overloaded function.</p> <p>Returns all visible items that, depending on <i>mode</i>, are either inside or intersect with the specified <i>rect</i> and return a list sorted using <i>order</i>.</p> <p>The default value for <i>mode</i> is <a href="qt.html#ItemSelectionMode-enum">Qt.IntersectsItemShape</a>; all items whose exact shape intersects with or is contained by <i>rect</i> are returned.</p> <p><i>deviceTransform</i> is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qgraphicsscene.html#itemAt">itemAt</a>() and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p> <h3 class="fn"><a name="items-11" />list-of-QGraphicsItem QGraphicsScene.items (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i> = Qt.IntersectsItemShape)</h3><p>This is an overloaded function.</p> <p>Returns all visible items that, depending on <i>mode</i>, are either inside or intersect with the specified <i>polygon</i> and return a list sorted using <i>order</i>.</p> <p>The default value for <i>mode</i> is <a href="qt.html#ItemSelectionMode-enum">Qt.IntersectsItemShape</a>; all items whose exact shape intersects with or is contained by <i>polygon</i> are returned.</p> <p><i>deviceTransform</i> is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qgraphicsscene.html#itemAt">itemAt</a>() and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p> <h3 class="fn"><a name="items-12" />list-of-QGraphicsItem QGraphicsScene.items (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i>, <a href="qt.html#SortOrder-enum">Qt.SortOrder</a> <i>order</i>, <a href="qtransform.html">QTransform</a> <i>deviceTransform</i> = QTransform())</h3><p>This is an overloaded function.</p> <p>Returns all visible items that, depending on <i>mode</i>, are either inside or intersect with the specified <i>path</i> and return a list sorted using <i>order</i>.</p> <p>The default value for <i>mode</i> is <a href="qt.html#ItemSelectionMode-enum">Qt.IntersectsItemShape</a>; all items whose exact shape intersects with or is contained by <i>path</i> are returned.</p> <p><i>deviceTransform</i> is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qgraphicsscene.html#itemAt">itemAt</a>() and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p> <h3 class="fn"><a name="itemsBoundingRect" /><a href="qrectf.html">QRectF</a> QGraphicsScene.itemsBoundingRect (<i>self</i>)</h3><p>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.</p> <p><b>See also</b> <a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a>().</p> <h3 class="fn"><a name="keyPressEvent" />QGraphicsScene.keyPressEvent (<i>self</i>, <a href="qkeyevent.html">QKeyEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>keyEvent</i>, can be reimplemented in a subclass to receive keypress events. The default implementation forwards the event to current focus item.</p> <p><b>See also</b> <a href="qgraphicsitem.html#keyPressEvent">QGraphicsItem.keyPressEvent</a>() and <a href="qgraphicsscene.html#focusItem">focusItem</a>().</p> <h3 class="fn"><a name="keyReleaseEvent" />QGraphicsScene.keyReleaseEvent (<i>self</i>, <a href="qkeyevent.html">QKeyEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>keyEvent</i>, can be reimplemented in a subclass to receive key release events. The default implementation forwards the event to current focus item.</p> <p><b>See also</b> <a href="qgraphicsitem.html#keyReleaseEvent">QGraphicsItem.keyReleaseEvent</a>() and <a href="qgraphicsscene.html#focusItem">focusItem</a>().</p> <h3 class="fn"><a name="mouseDoubleClickEvent" />QGraphicsScene.mouseDoubleClickEvent (<i>self</i>, <a href="qgraphicsscenemouseevent.html">QGraphicsSceneMouseEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>mouseEvent</i>, can be reimplemented in a subclass to receive mouse doubleclick events for the scene.</p> <p>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.</p> <p>The default implementation is similar to <a href="qgraphicsscene.html#mousePressEvent">mousePressEvent</a>().</p> <p><b>See also</b> <a href="qgraphicsitem.html#mousePressEvent">QGraphicsItem.mousePressEvent</a>(), <a href="qgraphicsitem.html#mouseMoveEvent">QGraphicsItem.mouseMoveEvent</a>(), <a href="qgraphicsitem.html#mouseReleaseEvent">QGraphicsItem.mouseReleaseEvent</a>(), and <a href="qgraphicsitem.html#setAcceptedMouseButtons">QGraphicsItem.setAcceptedMouseButtons</a>().</p> <h3 class="fn"><a name="mouseGrabberItem" /><a href="qgraphicsitem.html">QGraphicsItem</a> QGraphicsScene.mouseGrabberItem (<i>self</i>)</h3><p>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.</p> <p>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:</p> <ul> <li>If the item receives a mouse release event when there are no other buttons pressed, it loses the mouse grab.</li> <li>If the item becomes invisible (i.e., someone calls <tt>item->setVisible(false)</tt>), or if it becomes disabled (i.e., someone calls <tt>item->setEnabled(false)</tt>), it loses the mouse grab.</li> <li>If the item is removed from the scene, it loses the mouse grab.</li> </ul> <p>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).</p> <h3 class="fn"><a name="mouseMoveEvent" />QGraphicsScene.mouseMoveEvent (<i>self</i>, <a href="qgraphicsscenemouseevent.html">QGraphicsSceneMouseEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>mouseEvent</i>, can be reimplemented in a subclass to receive mouse move events for the scene.</p> <p>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.</p> <p><b>See also</b> <a href="qgraphicsitem.html#mousePressEvent">QGraphicsItem.mousePressEvent</a>(), <a href="qgraphicsitem.html#mouseReleaseEvent">QGraphicsItem.mouseReleaseEvent</a>(), <a href="qgraphicsitem.html#mouseDoubleClickEvent">QGraphicsItem.mouseDoubleClickEvent</a>(), and <a href="qgraphicsitem.html#setAcceptedMouseButtons">QGraphicsItem.setAcceptedMouseButtons</a>().</p> <h3 class="fn"><a name="mousePressEvent" />QGraphicsScene.mousePressEvent (<i>self</i>, <a href="qgraphicsscenemouseevent.html">QGraphicsSceneMouseEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>mouseEvent</i>, can be reimplemented in a subclass to receive mouse press events for the scene.</p> <p>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.</p> <p>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.</p> <p><b>See also</b> <a href="qgraphicsitem.html#mousePressEvent">QGraphicsItem.mousePressEvent</a>() and <a href="qgraphicsitem.html#setAcceptedMouseButtons">QGraphicsItem.setAcceptedMouseButtons</a>().</p> <h3 class="fn"><a name="mouseReleaseEvent" />QGraphicsScene.mouseReleaseEvent (<i>self</i>, <a href="qgraphicsscenemouseevent.html">QGraphicsSceneMouseEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>mouseEvent</i>, can be reimplemented in a subclass to receive mouse release events for the scene.</p> <p>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.</p> <p><b>See also</b> <a href="qgraphicsitem.html#mousePressEvent">QGraphicsItem.mousePressEvent</a>(), <a href="qgraphicsitem.html#mouseMoveEvent">QGraphicsItem.mouseMoveEvent</a>(), <a href="qgraphicsitem.html#mouseDoubleClickEvent">QGraphicsItem.mouseDoubleClickEvent</a>(), and <a href="qgraphicsitem.html#setAcceptedMouseButtons">QGraphicsItem.setAcceptedMouseButtons</a>().</p> <h3 class="fn"><a name="palette" /><a href="qpalette.html">QPalette</a> QGraphicsScene.palette (<i>self</i>)</h3><h3 class="fn"><a name="removeItem" />QGraphicsScene.removeItem (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a> <i>item</i>)</h3><p>The <i>item</i> argument</p><p>Removes the item <i>item</i> and all its children from the scene. The ownership of <i>item</i> is passed on to the caller (i.e., <a href="qgraphicsscene.html">QGraphicsScene</a> will no longer delete <i>item</i> when destroyed).</p> <p><b>See also</b> <a href="qgraphicsscene.html#addItem">addItem</a>().</p> <h3 class="fn"><a name="render" />QGraphicsScene.render (<i>self</i>, <a href="qpainter.html">QPainter</a> <i>painter</i>, <a href="qrectf.html">QRectF</a> <i>target</i> = QRectF(), <a href="qrectf.html">QRectF</a> <i>source</i> = QRectF(), <a href="qt.html#AspectRatioMode-enum">Qt.AspectRatioMode</a> <i>mode</i> = Qt.KeepAspectRatio)</h3><p>Renders the <i>source</i> rect from scene into <i>target</i>, using <i>painter</i>. This function is useful for capturing the contents of the scene onto a paint device, such as a <a href="qimage.html">QImage</a> (e.g., to take a screenshot), or for printing with <a href="qprinter.html">QPrinter</a>. For example:</p> <pre class="cpp"> <span class="type"><a href="qgraphicsscene.html">QGraphicsScene</a></span> scene; scene<span class="operator">.</span><a href="qgraphicsscene.html#addItem">addItem</a>(<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span> <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span> <span class="type"><a href="qprinter.html">QPrinter</a></span> printer(<span class="type"><a href="qprinter.html">QPrinter</a></span><span class="operator">.</span>HighResolution); printer<span class="operator">.</span>setPaperSize(<span class="type"><a href="qprinter.html">QPrinter</a></span><span class="operator">.</span>A4); <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="operator">&</span>printer); scene<span class="operator">.</span>render(<span class="operator">&</span>painter); </pre> <p>If <i>source</i> is a null rect, this function will use <a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a>() to determine what to render. If <i>target</i> is a null rect, the dimensions of <i>painter</i>'s paint device will be used.</p> <p>The source rect contents will be transformed according to <i>aspectRatioMode</i> to fit into the target rect. By default, the aspect ratio is kept, and <i>source</i> is scaled to fit in <i>target</i>.</p> <p><b>See also</b> <a href="qgraphicsview.html#render">QGraphicsView.render</a>().</p> <h3 class="fn"><a name="sceneRect" /><a href="qrectf.html">QRectF</a> QGraphicsScene.sceneRect (<i>self</i>)</h3><h3 class="fn"><a name="selectedItems" />list-of-QGraphicsItem QGraphicsScene.selectedItems (<i>self</i>)</h3><p>Returns a list of all currently selected items. The items are returned in no particular order.</p> <p><b>See also</b> <a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a>().</p> <h3 class="fn"><a name="selectionArea" /><a href="qpainterpath.html">QPainterPath</a> QGraphicsScene.selectionArea (<i>self</i>)</h3><p>Returns the selection area that was previously set with <a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a>(), or an empty <a href="qpainterpath.html">QPainterPath</a> if no selection area has been set.</p> <p><b>See also</b> <a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a>().</p> <h3 class="fn"><a name="sendEvent" />bool QGraphicsScene.sendEvent (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a> <i>item</i>, <a href="qevent.html">QEvent</a> <i>event</i>)</h3><p>Sends event <i>event</i> to item <i>item</i> through possible event filters.</p> <p>The event is sent only if the item is enabled.</p> <p>Returns <tt>false</tt> if the event was filtered or if the item is disabled. Otherwise returns the value that was returned from the event handler.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qgraphicsitem.html#sceneEvent">QGraphicsItem.sceneEvent</a>() and <a href="qgraphicsitem.html#sceneEventFilter">QGraphicsItem.sceneEventFilter</a>().</p> <h3 class="fn"><a name="setActivePanel" />QGraphicsScene.setActivePanel (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a> <i>item</i>)</h3><p>Activates <i>item</i>, which must be an item in this scene. You can also pass 0 for <i>item</i>, in which case <a href="qgraphicsscene.html">QGraphicsScene</a> will deactivate any currently active panel.</p> <p>If the scene is currently inactive, <i>item</i> remains inactive until the scene becomes active (or, ir <i>item</i> is 0, no item will be activated).</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qgraphicsscene.html#activePanel">activePanel</a>(), <a href="qgraphicsscene.html#isActive">isActive</a>(), and <a href="qgraphicsitem.html#isActive">QGraphicsItem.isActive</a>().</p> <h3 class="fn"><a name="setActiveWindow" />QGraphicsScene.setActiveWindow (<i>self</i>, <a href="qgraphicswidget.html">QGraphicsWidget</a> <i>widget</i>)</h3><p>Activates <i>widget</i>, which must be a widget in this scene. You can also pass 0 for <i>widget</i>, in which case <a href="qgraphicsscene.html">QGraphicsScene</a> will deactivate any currently active window.</p> <p>This function was introduced in Qt 4.4.</p> <p><b>See also</b> <a href="qgraphicsscene.html#activeWindow">activeWindow</a>() and <a href="qgraphicswidget.html#isActiveWindow">QGraphicsWidget.isActiveWindow</a>().</p> <h3 class="fn"><a name="setBackgroundBrush" />QGraphicsScene.setBackgroundBrush (<i>self</i>, <a href="qbrush.html">QBrush</a> <i>brush</i>)</h3><h3 class="fn"><a name="setBspTreeDepth" />QGraphicsScene.setBspTreeDepth (<i>self</i>, int <i>depth</i>)</h3><h3 class="fn"><a name="setFocus" />QGraphicsScene.setFocus (<i>self</i>, <a href="qt.html#FocusReason-enum">Qt.FocusReason</a> <i>focusReason</i> = Qt.OtherFocusReason)</h3><p>Sets focus on the scene by sending a <a href="qfocusevent.html">QFocusEvent</a> to the scene, passing <i>focusReason</i> 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 <i>focusReason</i> as the reason.</p> <p>If the scene already has focus, this function does nothing.</p> <p><b>See also</b> <a href="qgraphicsscene.html#hasFocus">hasFocus</a>(), <a href="qgraphicsscene.html#clearFocus">clearFocus</a>(), and <a href="qgraphicsscene.html#setFocusItem">setFocusItem</a>().</p> <h3 class="fn"><a name="setFocusItem" />QGraphicsScene.setFocusItem (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a> <i>item</i>, <a href="qt.html#FocusReason-enum">Qt.FocusReason</a> <i>focusReason</i> = Qt.OtherFocusReason)</h3><p>Sets the scene's focus item to <i>item</i>, with the focus reason <i>focusReason</i>, after removing focus from any previous item that may have had focus.</p> <p>If <i>item</i> is 0, or if it either does not accept focus (i.e., it does not have the <a href="qgraphicsitem.html#GraphicsItemFlag-enum">QGraphicsItem.ItemIsFocusable</a> flag enabled), or is not visible or not enabled, this function only removes focus from any previous focusitem.</p> <p>If item is not 0, and the scene does not currently have focus (i.e., <a href="qgraphicsscene.html#hasFocus">hasFocus</a>() returns false), this function will call <a href="qgraphicsscene.html#setFocus">setFocus</a>() automatically.</p> <p><b>See also</b> <a href="qgraphicsscene.html#focusItem">focusItem</a>(), <a href="qgraphicsscene.html#hasFocus">hasFocus</a>(), and <a href="qgraphicsscene.html#setFocus">setFocus</a>().</p> <h3 class="fn"><a name="setFont" />QGraphicsScene.setFont (<i>self</i>, <a href="qfont.html">QFont</a> <i>font</i>)</h3><h3 class="fn"><a name="setForegroundBrush" />QGraphicsScene.setForegroundBrush (<i>self</i>, <a href="qbrush.html">QBrush</a> <i>brush</i>)</h3><h3 class="fn"><a name="setItemIndexMethod" />QGraphicsScene.setItemIndexMethod (<i>self</i>, <a href="qgraphicsscene.html#ItemIndexMethod-enum">ItemIndexMethod</a> <i>method</i>)</h3><h3 class="fn"><a name="setPalette" />QGraphicsScene.setPalette (<i>self</i>, <a href="qpalette.html">QPalette</a> <i>palette</i>)</h3><h3 class="fn"><a name="setSceneRect" />QGraphicsScene.setSceneRect (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>)</h3><h3 class="fn"><a name="setSceneRect-2" />QGraphicsScene.setSceneRect (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>)</h3><h3 class="fn"><a name="setSelectionArea" />QGraphicsScene.setSelectionArea (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>path</i>, <a href="qtransform.html">QTransform</a> <i>deviceTransform</i>)</h3><p>Sets the selection area to <i>path</i>. 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 <a href="qgraphicsscene.html#selectedItems">selectedItems</a>().</p> <p><i>deviceTransform</i> is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.</p> <p>For an item to be selected, it must be marked as <i>selectable</i> (<a href="qgraphicsitem.html#GraphicsItemFlag-enum">QGraphicsItem.ItemIsSelectable</a>).</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qgraphicsscene.html#clearSelection">clearSelection</a>() and <a href="qgraphicsscene.html#selectionArea">selectionArea</a>().</p> <h3 class="fn"><a name="setSelectionArea-2" />QGraphicsScene.setSelectionArea (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>path</i>)</h3><h3 class="fn"><a name="setSelectionArea-3" />QGraphicsScene.setSelectionArea (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>path</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a>)</h3><h3 class="fn"><a name="setSelectionArea-4" />QGraphicsScene.setSelectionArea (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>path</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i>, <a href="qtransform.html">QTransform</a> <i>deviceTransform</i>)</h3><p>This is an overloaded function.</p> <p>Sets the selection area to <i>path</i> using <i>mode</i> to determine if items are included in the selection area.</p> <p><i>deviceTransform</i> is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qgraphicsscene.html#clearSelection">clearSelection</a>() and <a href="qgraphicsscene.html#selectionArea">selectionArea</a>().</p> <h3 class="fn"><a name="setSortCacheEnabled" />QGraphicsScene.setSortCacheEnabled (<i>self</i>, bool <i>enabled</i>)</h3><h3 class="fn"><a name="setStickyFocus" />QGraphicsScene.setStickyFocus (<i>self</i>, bool <i>enabled</i>)</h3><h3 class="fn"><a name="setStyle" />QGraphicsScene.setStyle (<i>self</i>, <a href="qstyle.html">QStyle</a> <i>style</i>)</h3><p>The <i>style</i> argument has it's ownership transferred to Qt.</p><p>Sets or replaces the style of the scene to <i>style</i>, and reparents the style to this scene. Any previously assigned style is deleted. The scene's style defaults to <a href="qapplication.html#style">QApplication.style</a>(), and serves as the default for all <a href="qgraphicswidget.html">QGraphicsWidget</a> items in the scene.</p> <p>Changing the style, either directly by calling this function, or indirectly by calling <a href="qapplication.html#setStyle">QApplication.setStyle</a>(), will automatically update the style for all widgets in the scene that do not have a style explicitly assigned to them.</p> <p>If <i>style</i> is 0, <a href="qgraphicsscene.html">QGraphicsScene</a> will revert to <a href="qapplication.html#style">QApplication.style</a>().</p> <p>This function was introduced in Qt 4.4.</p> <p><b>See also</b> <a href="qgraphicsscene.html#style">style</a>().</p> <h3 class="fn"><a name="stickyFocus" />bool QGraphicsScene.stickyFocus (<i>self</i>)</h3><h3 class="fn"><a name="style" /><a href="qstyle.html">QStyle</a> QGraphicsScene.style (<i>self</i>)</h3><p>Returns the scene's style, or the same as <a href="qapplication.html#style">QApplication.style</a>() if the scene has not been explicitly assigned a style.</p> <p>This function was introduced in Qt 4.4.</p> <p><b>See also</b> <a href="qgraphicsscene.html#setStyle">setStyle</a>().</p> <h3 class="fn"><a name="update" />QGraphicsScene.update (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i> = QRectF())</h3><p>This method is also a Qt slot with the C++ signature <tt>void update(const QRectF& = QRectF())</tt>.</p><p>Schedules a redraw of the area <i>rect</i> on the scene.</p> <p><b>See also</b> <a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a>() and <a href="qgraphicsscene.html#changed">changed</a>().</p> <h3 class="fn"><a name="update-2" />QGraphicsScene.update (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>)</h3><p>This is an overloaded function.</p> <p>This function is equivalent to calling update(<a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>));</p> <p>This function was introduced in Qt 4.3.</p> <h3 class="fn"><a name="views" />list-of-QGraphicsView QGraphicsScene.views (<i>self</i>)</h3><p>Returns a list of all the views that display this scene.</p> <p><b>See also</b> <a href="qgraphicsview.html#scene">QGraphicsView.scene</a>().</p> <h3 class="fn"><a name="wheelEvent" />QGraphicsScene.wheelEvent (<i>self</i>, <a href="qgraphicsscenewheelevent.html">QGraphicsSceneWheelEvent</a> <i>event</i>)</h3><p>This event handler, for event <i>wheelEvent</i>, can be reimplemented in a subclass to receive mouse wheel events for the scene.</p> <p>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.</p> <p><b>See also</b> <a href="qgraphicsitem.html#wheelEvent">QGraphicsItem.wheelEvent</a>().</p> <h3 class="fn"><a name="width" />float QGraphicsScene.width (<i>self</i>)</h3><p>This convenience function is equivalent to calling <a href="qgraphicsscene.html#sceneRect-prop">sceneRect</a>().width().</p> <p><b>See also</b> <a href="qgraphicsscene.html#height">height</a>().</p> <hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="changed" />void changed (const QList<QRectF>&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted by <a href="qgraphicsscene.html">QGraphicsScene</a> when control reaches the event loop, if the scene content changes. The <i>region</i> parameter contains a list of scene rectangles that indicate the area that has been changed.</p> <p><b>See also</b> <a href="qgraphicsview.html#updateScene">QGraphicsView.updateScene</a>().</p> <h3 class="fn"><a name="sceneRectChanged" />void sceneRectChanged (const QRectF&)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted by <a href="qgraphicsscene.html">QGraphicsScene</a> whenever the scene rect changes. The <i>rect</i> parameter is the new scene rectangle.</p> <p><b>See also</b> <a href="qgraphicsview.html#updateSceneRect">QGraphicsView.updateSceneRect</a>().</p> <h3 class="fn"><a name="selectionChanged" />void selectionChanged ()</h3><p>This is the default overload of this signal.</p><p>This signal is emitted by <a href="qgraphicsscene.html">QGraphicsScene</a> whenever the selection changes. You can call <a href="qgraphicsscene.html#selectedItems">selectedItems</a>() to get the new list of selected items.</p> <p>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.</p> <p><a href="qgraphicsscene.html">QGraphicsScene</a> emits this signal only once for group selection operations. For example, if you set a selection area, select or unselect a <a href="qgraphicsitemgroup.html">QGraphicsItemGroup</a>, 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).</p> <p>This function was introduced in Qt 4.3.</p> <p><b>See also</b> <a href="qgraphicsscene.html#setSelectionArea">setSelectionArea</a>(), <a href="qgraphicsscene.html#selectedItems">selectedItems</a>(), and <a href="qgraphicsitem.html#setSelected">QGraphicsItem.setSelected</a>().</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>