1
<?xml version="1.0" encoding="iso-8859-1"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
3
<html><head><title>QGraphicsView Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
4
a:link { color: #004faf; text-decoration: none }
5
a:visited { color: #672967; text-decoration: none }
6
td.postheader { font-family: sans-serif }
7
tr.address { font-family: sans-serif }
8
body { background: #ffffff; color: black; }
9
</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">QGraphicsView Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QGraphicsView class provides a widget for displaying the
10
contents of a <a href="qgraphicsscene.html">QGraphicsScene</a>.
11
<a href="#details">More...</a></p>
13
<p>Inherits <a href="qabstractscrollarea.html">QAbstractScrollArea</a>.</p><p>Inherited by <a href="qdeclarativeview.html">QDeclarativeView</a>.</p><h3>Types</h3><ul><li><div class="fn" />class <b><a href="qgraphicsview-cachemode.html">CacheMode</a></b></li><li><div class="fn" />enum <b><a href="qgraphicsview.html#CacheModeFlag-enum">CacheModeFlag</a></b> { CacheNone, CacheBackground }</li><li><div class="fn" />enum <b><a href="qgraphicsview.html#DragMode-enum">DragMode</a></b> { NoDrag, ScrollHandDrag, RubberBandDrag }</li><li><div class="fn" />enum <b><a href="qgraphicsview.html#OptimizationFlag-enum">OptimizationFlag</a></b> { DontClipPainter, DontSavePainterState, DontAdjustForAntialiasing }</li><li><div class="fn" />class <b><a href="qgraphicsview-optimizationflags.html">OptimizationFlags</a></b></li><li><div class="fn" />enum <b><a href="qgraphicsview.html#ViewportAnchor-enum">ViewportAnchor</a></b> { NoAnchor, AnchorViewCenter, AnchorUnderMouse }</li><li><div class="fn" />enum <b><a href="qgraphicsview.html#ViewportUpdateMode-enum">ViewportUpdateMode</a></b> { FullViewportUpdate, MinimalViewportUpdate, SmartViewportUpdate, BoundingRectViewportUpdate, NoViewportUpdate }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qgraphicsview.html#QGraphicsView">__init__</a></b> (<i>self</i>, QWidget <i>parent</i> = None)</li><li><div class="fn" /><b><a href="qgraphicsview.html#QGraphicsView-2">__init__</a></b> (<i>self</i>, QGraphicsScene <i>scene</i>, QWidget <i>parent</i> = None)</li><li><div class="fn" />Qt.Alignment <b><a href="qgraphicsview.html#alignment">alignment</a></b> (<i>self</i>)</li><li><div class="fn" />QBrush <b><a href="qgraphicsview.html#backgroundBrush">backgroundBrush</a></b> (<i>self</i>)</li><li><div class="fn" />CacheMode <b><a href="qgraphicsview.html#cacheMode">cacheMode</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#centerOn">centerOn</a></b> (<i>self</i>, QPointF <i>pos</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#centerOn-2">centerOn</a></b> (<i>self</i>, QGraphicsItem <i>item</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#centerOn-3">centerOn</a></b> (<i>self</i>, float <i>ax</i>, float <i>ay</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#contextMenuEvent">contextMenuEvent</a></b> (<i>self</i>, QContextMenuEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#dragEnterEvent">dragEnterEvent</a></b> (<i>self</i>, QDragEnterEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#dragLeaveEvent">dragLeaveEvent</a></b> (<i>self</i>, QDragLeaveEvent <i>event</i>)</li><li><div class="fn" />DragMode <b><a href="qgraphicsview.html#dragMode">dragMode</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#dragMoveEvent">dragMoveEvent</a></b> (<i>self</i>, QDragMoveEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#drawBackground">drawBackground</a></b> (<i>self</i>, QPainter <i>painter</i>, QRectF <i>rect</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#drawForeground">drawForeground</a></b> (<i>self</i>, QPainter <i>painter</i>, QRectF <i>rect</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#drawItems">drawItems</a></b> (<i>self</i>, QPainter <i>painter</i>, list-of-QGraphicsItem <i>items</i>, list-of-QStyleOptionGraphicsItem <i>options</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#dropEvent">dropEvent</a></b> (<i>self</i>, QDropEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#ensureVisible">ensureVisible</a></b> (<i>self</i>, QRectF <i>rect</i>, int <i>xMargin</i> = 50, int <i>yMargin</i> = 50)</li><li><div class="fn" /><b><a href="qgraphicsview.html#ensureVisible-2">ensureVisible</a></b> (<i>self</i>, QGraphicsItem <i>item</i>, int <i>xMargin</i> = 50, int <i>yMargin</i> = 50)</li><li><div class="fn" /><b><a href="qgraphicsview.html#ensureVisible-3">ensureVisible</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, int <i>xMargin</i> = 50, int <i>yMargin</i> = 50)</li><li><div class="fn" />bool <b><a href="qgraphicsview.html#event">event</a></b> (<i>self</i>, QEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#fitInView">fitInView</a></b> (<i>self</i>, QRectF <i>rect</i>, Qt.AspectRatioMode <i>mode</i> = Qt.IgnoreAspectRatio)</li><li><div class="fn" /><b><a href="qgraphicsview.html#fitInView-2">fitInView</a></b> (<i>self</i>, QGraphicsItem <i>item</i>, Qt.AspectRatioMode <i>mode</i> = Qt.IgnoreAspectRatio)</li><li><div class="fn" /><b><a href="qgraphicsview.html#fitInView-3">fitInView</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, Qt.AspectRatioMode <i>mode</i> = Qt.IgnoreAspectRatio)</li><li><div class="fn" /><b><a href="qgraphicsview.html#focusInEvent">focusInEvent</a></b> (<i>self</i>, QFocusEvent <i>event</i>)</li><li><div class="fn" />bool <b><a href="qgraphicsview.html#focusNextPrevChild">focusNextPrevChild</a></b> (<i>self</i>, bool <i>next</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#focusOutEvent">focusOutEvent</a></b> (<i>self</i>, QFocusEvent <i>event</i>)</li><li><div class="fn" />QBrush <b><a href="qgraphicsview.html#foregroundBrush">foregroundBrush</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#inputMethodEvent">inputMethodEvent</a></b> (<i>self</i>, QInputMethodEvent <i>event</i>)</li><li><div class="fn" />QVariant <b><a href="qgraphicsview.html#inputMethodQuery">inputMethodQuery</a></b> (<i>self</i>, Qt.InputMethodQuery <i>query</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#invalidateScene">invalidateScene</a></b> (<i>self</i>, QRectF <i>rect</i> = QRectF(), QGraphicsScene.SceneLayers <i>layers</i> = QGraphicsScene.AllLayers)</li><li><div class="fn" />bool <b><a href="qgraphicsview.html#isInteractive">isInteractive</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qgraphicsview.html#isTransformed">isTransformed</a></b> (<i>self</i>)</li><li><div class="fn" />QGraphicsItem <b><a href="qgraphicsview.html#itemAt">itemAt</a></b> (<i>self</i>, QPoint <i>pos</i>)</li><li><div class="fn" />QGraphicsItem <b><a href="qgraphicsview.html#itemAt-2">itemAt</a></b> (<i>self</i>, int <i>ax</i>, int <i>ay</i>)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsview.html#items">items</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsview.html#items-2">items</a></b> (<i>self</i>, QPoint <i>pos</i>)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsview.html#items-3">items</a></b> (<i>self</i>, int <i>ax</i>, int <i>ay</i>)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsview.html#items-4">items</a></b> (<i>self</i>, int <i>x</i>, int <i>y</i>, int <i>w</i>, int <i>h</i>, Qt.ItemSelectionMode <i>mode</i> = Qt.IntersectsItemShape)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsview.html#items-5">items</a></b> (<i>self</i>, QRect <i>rect</i>, Qt.ItemSelectionMode <i>mode</i> = Qt.IntersectsItemShape)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsview.html#items-6">items</a></b> (<i>self</i>, QPolygon <i>polygon</i>, Qt.ItemSelectionMode <i>mode</i> = Qt.IntersectsItemShape)</li><li><div class="fn" />list-of-QGraphicsItem <b><a href="qgraphicsview.html#items-7">items</a></b> (<i>self</i>, QPainterPath <i>path</i>, Qt.ItemSelectionMode <i>mode</i> = Qt.IntersectsItemShape)</li><li><div class="fn" /><b><a href="qgraphicsview.html#keyPressEvent">keyPressEvent</a></b> (<i>self</i>, QKeyEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#keyReleaseEvent">keyReleaseEvent</a></b> (<i>self</i>, QKeyEvent <i>event</i>)</li><li><div class="fn" />QPoint <b><a href="qgraphicsview.html#mapFromScene">mapFromScene</a></b> (<i>self</i>, QPointF <i>point</i>)</li><li><div class="fn" />QPolygon <b><a href="qgraphicsview.html#mapFromScene-2">mapFromScene</a></b> (<i>self</i>, QRectF <i>rect</i>)</li><li><div class="fn" />QPolygon <b><a href="qgraphicsview.html#mapFromScene-3">mapFromScene</a></b> (<i>self</i>, QPolygonF <i>polygon</i>)</li><li><div class="fn" />QPainterPath <b><a href="qgraphicsview.html#mapFromScene-4">mapFromScene</a></b> (<i>self</i>, QPainterPath <i>path</i>)</li><li><div class="fn" />QPoint <b><a href="qgraphicsview.html#mapFromScene-5">mapFromScene</a></b> (<i>self</i>, float <i>ax</i>, float <i>ay</i>)</li><li><div class="fn" />QPolygon <b><a href="qgraphicsview.html#mapFromScene-6">mapFromScene</a></b> (<i>self</i>, float <i>ax</i>, float <i>ay</i>, float <i>w</i>, float <i>h</i>)</li><li><div class="fn" />QPointF <b><a href="qgraphicsview.html#mapToScene">mapToScene</a></b> (<i>self</i>, QPoint <i>point</i>)</li><li><div class="fn" />QPolygonF <b><a href="qgraphicsview.html#mapToScene-2">mapToScene</a></b> (<i>self</i>, QRect <i>rect</i>)</li><li><div class="fn" />QPolygonF <b><a href="qgraphicsview.html#mapToScene-3">mapToScene</a></b> (<i>self</i>, QPolygon <i>polygon</i>)</li><li><div class="fn" />QPainterPath <b><a href="qgraphicsview.html#mapToScene-4">mapToScene</a></b> (<i>self</i>, QPainterPath <i>path</i>)</li><li><div class="fn" />QPointF <b><a href="qgraphicsview.html#mapToScene-5">mapToScene</a></b> (<i>self</i>, int <i>ax</i>, int <i>ay</i>)</li><li><div class="fn" />QPolygonF <b><a href="qgraphicsview.html#mapToScene-6">mapToScene</a></b> (<i>self</i>, int <i>ax</i>, int <i>ay</i>, int <i>w</i>, int <i>h</i>)</li><li><div class="fn" />QMatrix <b><a href="qgraphicsview.html#matrix">matrix</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#mouseDoubleClickEvent">mouseDoubleClickEvent</a></b> (<i>self</i>, QMouseEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#mouseMoveEvent">mouseMoveEvent</a></b> (<i>self</i>, QMouseEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#mousePressEvent">mousePressEvent</a></b> (<i>self</i>, QMouseEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#mouseReleaseEvent">mouseReleaseEvent</a></b> (<i>self</i>, QMouseEvent <i>event</i>)</li><li><div class="fn" />OptimizationFlags <b><a href="qgraphicsview.html#optimizationFlags">optimizationFlags</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#paintEvent">paintEvent</a></b> (<i>self</i>, QPaintEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#render">render</a></b> (<i>self</i>, QPainter <i>painter</i>, QRectF <i>target</i> = QRectF(), QRect <i>source</i> = QRect(), Qt.AspectRatioMode <i>mode</i> = Qt.KeepAspectRatio)</li><li><div class="fn" />QPainter.RenderHints <b><a href="qgraphicsview.html#renderHints">renderHints</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#resetCachedContent">resetCachedContent</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#resetMatrix">resetMatrix</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#resetTransform">resetTransform</a></b> (<i>self</i>)</li><li><div class="fn" />ViewportAnchor <b><a href="qgraphicsview.html#resizeAnchor">resizeAnchor</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#resizeEvent">resizeEvent</a></b> (<i>self</i>, QResizeEvent <i>event</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#rotate">rotate</a></b> (<i>self</i>, float <i>angle</i>)</li><li><div class="fn" />Qt.ItemSelectionMode <b><a href="qgraphicsview.html#rubberBandSelectionMode">rubberBandSelectionMode</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#scale">scale</a></b> (<i>self</i>, float <i>sx</i>, float <i>sy</i>)</li><li><div class="fn" />QGraphicsScene <b><a href="qgraphicsview.html#scene">scene</a></b> (<i>self</i>)</li><li><div class="fn" />QRectF <b><a href="qgraphicsview.html#sceneRect">sceneRect</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#scrollContentsBy">scrollContentsBy</a></b> (<i>self</i>, int <i>dx</i>, int <i>dy</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setAlignment">setAlignment</a></b> (<i>self</i>, Qt.Alignment <i>alignment</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setBackgroundBrush">setBackgroundBrush</a></b> (<i>self</i>, QBrush <i>brush</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setCacheMode">setCacheMode</a></b> (<i>self</i>, CacheMode <i>mode</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setDragMode">setDragMode</a></b> (<i>self</i>, DragMode <i>mode</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setForegroundBrush">setForegroundBrush</a></b> (<i>self</i>, QBrush <i>brush</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setInteractive">setInteractive</a></b> (<i>self</i>, bool <i>allowed</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setMatrix">setMatrix</a></b> (<i>self</i>, QMatrix <i>matrix</i>, bool <i>combine</i> = False)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setOptimizationFlag">setOptimizationFlag</a></b> (<i>self</i>, OptimizationFlag <i>flag</i>, bool <i>enabled</i> = True)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setOptimizationFlags">setOptimizationFlags</a></b> (<i>self</i>, OptimizationFlags <i>flags</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setRenderHint">setRenderHint</a></b> (<i>self</i>, QPainter.RenderHint <i>hint</i>, bool <i>on</i> = True)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setRenderHints">setRenderHints</a></b> (<i>self</i>, QPainter.RenderHints <i>hints</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setResizeAnchor">setResizeAnchor</a></b> (<i>self</i>, ViewportAnchor <i>anchor</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setRubberBandSelectionMode">setRubberBandSelectionMode</a></b> (<i>self</i>, Qt.ItemSelectionMode <i>mode</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setScene">setScene</a></b> (<i>self</i>, QGraphicsScene <i>scene</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setSceneRect">setSceneRect</a></b> (<i>self</i>, QRectF <i>rect</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setSceneRect-2">setSceneRect</a></b> (<i>self</i>, float <i>ax</i>, float <i>ay</i>, float <i>aw</i>, float <i>ah</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setTransform">setTransform</a></b> (<i>self</i>, QTransform <i>matrix</i>, bool <i>combine</i> = False)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setTransformationAnchor">setTransformationAnchor</a></b> (<i>self</i>, ViewportAnchor <i>anchor</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setupViewport">setupViewport</a></b> (<i>self</i>, QWidget <i>widget</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#setViewportUpdateMode">setViewportUpdateMode</a></b> (<i>self</i>, ViewportUpdateMode <i>mode</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#shear">shear</a></b> (<i>self</i>, float <i>sh</i>, float <i>sv</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#showEvent">showEvent</a></b> (<i>self</i>, QShowEvent <i>event</i>)</li><li><div class="fn" />QSize <b><a href="qgraphicsview.html#sizeHint">sizeHint</a></b> (<i>self</i>)</li><li><div class="fn" />QTransform <b><a href="qgraphicsview.html#transform">transform</a></b> (<i>self</i>)</li><li><div class="fn" />ViewportAnchor <b><a href="qgraphicsview.html#transformationAnchor">transformationAnchor</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#translate">translate</a></b> (<i>self</i>, float <i>dx</i>, float <i>dy</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#updateScene">updateScene</a></b> (<i>self</i>, list-of-QRectF <i>rects</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#updateSceneRect">updateSceneRect</a></b> (<i>self</i>, QRectF <i>rect</i>)</li><li><div class="fn" />bool <b><a href="qgraphicsview.html#viewportEvent">viewportEvent</a></b> (<i>self</i>, QEvent <i>event</i>)</li><li><div class="fn" />QTransform <b><a href="qgraphicsview.html#viewportTransform">viewportTransform</a></b> (<i>self</i>)</li><li><div class="fn" />ViewportUpdateMode <b><a href="qgraphicsview.html#viewportUpdateMode">viewportUpdateMode</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsview.html#wheelEvent">wheelEvent</a></b> (<i>self</i>, QWheelEvent <i>event</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QGraphicsView class provides a widget for displaying the
14
contents of a <a href="qgraphicsscene.html">QGraphicsScene</a>.</p>
15
<p>QGraphicsView visualizes the contents of a <a href="qgraphicsscene.html">QGraphicsScene</a> in a scrollable viewport.
16
To create a scene with geometrical items, see <a href="qgraphicsscene.html">QGraphicsScene</a>'s documentation.
17
QGraphicsView is part of the <a href="graphicsview.html">Graphics
18
View Framework</a>.</p>
19
<p>To visualize a scene, you start by constructing a QGraphicsView
20
object, passing the address of the scene you want to visualize to
21
QGraphicsView's constructor. Alternatively, you can call <a href="qgraphicsview.html#setScene">setScene</a>() to set the scene at a
22
later point. After you call <a href="qwidget.html#show">show</a>(),
23
the view will by default scroll to the center of the scene and
24
display any items that are visible at this point. For example:</p>
26
<span class="type"><a href="qgraphicsscene.html">QGraphicsScene</a></span> scene;
27
scene<span class="operator">.</span>addText(<span class="string">"Hello, world!"</span>);
29
<span class="type">QGraphicsView</span> view(<span class="operator">&</span>scene);
30
view<span class="operator">.</span><a href="qwidget.html#show">show</a>();
32
<p>You can explicitly scroll to any position on the scene by using
33
the scroll bars, or by calling <a href="qgraphicsview.html#centerOn">centerOn</a>(). By passing a point to
34
<a href="qgraphicsview.html#centerOn">centerOn</a>(), QGraphicsView
35
will scroll its viewport to ensure that the point is centered in
36
the view. An overload is provided for scrolling to a <a href="qgraphicsitem.html">QGraphicsItem</a>, in which case QGraphicsView
37
will see to that the center of the item is centered in the view. If
38
all you want is to ensure that a certain area is visible, (but not
39
necessarily centered,) you can call <a href="qgraphicsview.html#ensureVisible">ensureVisible</a>() instead.</p>
40
<p>QGraphicsView can be used to visualize a whole scene, or only
41
parts of it. The visualized area is by default detected
42
automatically when the view is displayed for the first time (by
43
calling <a href="qgraphicsscene.html#itemsBoundingRect">QGraphicsScene.itemsBoundingRect</a>()).
44
To set the visualized area rectangle yourself, you can call
45
<a href="qgraphicsview.html#sceneRect-prop">setSceneRect</a>().
46
This will adjust the scroll bars' ranges appropriately. Note that
47
although the scene supports a virtually unlimited size, the range
48
of the scroll bars will never exceed the range of an integer
49
(INT_MIN, INT_MAX).</p>
50
<p>QGraphicsView visualizes the scene by calling <a href="qgraphicsview.html#render">render</a>(). By default, the items are
51
drawn onto the viewport by using a regular <a href="qpainter.html">QPainter</a>, and using default render hints. To
52
change the default render hints that QGraphicsView passes to
53
<a href="qpainter.html">QPainter</a> when painting items, you can
54
call <a href="qgraphicsview.html#renderHints-prop">setRenderHints</a>().</p>
55
<p>By default, QGraphicsView provides a regular <a href="qwidget.html">QWidget</a> for the viewport widget. You can access
56
this widget by calling <a href="qabstractscrollarea.html#viewport">viewport</a>(), or you can
57
replace it by calling <a href="qabstractscrollarea.html#setViewport">setViewport</a>(). To render
58
using OpenGL, simply call setViewport(new <a href="qglwidget.html">QGLWidget</a>). QGraphicsView takes ownership of
59
the viewport widget.</p>
60
<p>QGraphicsView supports affine transformations, using <a href="qtransform.html">QTransform</a>. You can either pass a matrix to
61
<a href="qgraphicsview.html#setTransform">setTransform</a>(), or
62
you can call one of the convenience functions <a href="qgraphicsview.html#rotate">rotate</a>(), <a href="qgraphicsview.html#scale">scale</a>(), <a href="qgraphicsview.html#translate">translate</a>() or <a href="qgraphicsview.html#shear">shear</a>(). The most two common
63
transformations are scaling, which is used to implement zooming,
64
and rotation. QGraphicsView keeps the center of the view fixed
65
during a transformation. Because of the scene alignment
66
(setAligment()), translating the view will have no visual
68
<p>You can interact with the items on the scene by using the mouse
69
and keyboard. QGraphicsView translates the mouse and key events
70
into <i>scene</i> events, (events that inherit <a href="qgraphicssceneevent.html">QGraphicsSceneEvent</a>,), and forward
71
them to the visualized scene. In the end, it's the individual item
72
that handles the events and reacts to them. For example, if you
73
click on a selectable item, the item will typically let the scene
74
know that it has been selected, and it will also redraw itself to
75
display a selection rectangle. Similiary, if you click and drag the
76
mouse to move a movable item, it's the item that handles the mouse
77
moves and moves itself. Item interaction is enabled by default, and
78
you can toggle it by calling <a href="qgraphicsview.html#interactive-prop">setInteractive</a>().</p>
79
<p>You can also provide your own custom scene interaction, by
80
creating a subclass of QGraphicsView, and reimplementing the mouse
81
and key event handlers. To simplify how you programmatically
82
interact with items in the view, QGraphicsView provides the mapping
83
functions <a href="qgraphicsview.html#mapToScene">mapToScene</a>()
84
and <a href="qgraphicsview.html#mapFromScene">mapFromScene</a>(),
85
and the item accessors <a href="qgraphicsview.html#items">items</a>() and <a href="qgraphicsview.html#itemAt">itemAt</a>(). These functions allow you
86
to map points, rectangles, polygons and paths between view
87
coordinates and scene coordinates, and to find items on the scene
88
using view coordinates.</p>
89
<p class="centerAlign"><img alt="" src="images/graphicsview-view.png" /></p>
90
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="CacheModeFlag-enum" />QGraphicsView.CacheModeFlag</h3><p>This enum describes the flags that you can set for a <a href="qgraphicsview.html">QGraphicsView</a>'s cache mode.</p>
91
<table class="valuelist">
92
<tr class="odd" valign="top">
93
<th class="tblConst">Constant</th>
94
<th class="tblval">Value</th>
95
<th class="tbldscr">Description</th>
98
<td class="topAlign"><tt>QGraphicsView.CacheNone</tt></td>
99
<td class="topAlign"><tt>0x0</tt></td>
100
<td class="topAlign">All painting is done directly onto the
104
<td class="topAlign"><tt>QGraphicsView.CacheBackground</tt></td>
105
<td class="topAlign"><tt>0x1</tt></td>
106
<td class="topAlign">The background is cached. This affects both
107
custom backgrounds, and backgrounds based on the <a href="qgraphicsview.html#backgroundBrush-prop">backgroundBrush</a>
108
property. When this flag is enabled, <a href="qgraphicsview.html">QGraphicsView</a> will allocate one pixmap
109
with the full size of the viewport.</td>
112
<p>The CacheMode type is a typedef for <a href="qflags.html">QFlags</a><CacheModeFlag>. It stores an OR
113
combination of CacheModeFlag values.</p>
114
<p><b>See also</b> <a href="qgraphicsview.html#cacheMode-prop">cacheMode</a>.</p>
117
<h3 class="fn"><a name="DragMode-enum" />QGraphicsView.DragMode</h3><p>This enum describes the default action for the view when
118
pressing and dragging the mouse over the viewport.</p>
119
<table class="valuelist">
120
<tr class="odd" valign="top">
121
<th class="tblConst">Constant</th>
122
<th class="tblval">Value</th>
123
<th class="tbldscr">Description</th>
126
<td class="topAlign"><tt>QGraphicsView.NoDrag</tt></td>
127
<td class="topAlign"><tt>0</tt></td>
128
<td class="topAlign">Nothing happens; the mouse event is
132
<td class="topAlign"><tt>QGraphicsView.ScrollHandDrag</tt></td>
133
<td class="topAlign"><tt>1</tt></td>
134
<td class="topAlign">The cursor changes into a pointing hand, and
135
dragging the mouse around will scroll the scrolbars. This mode
136
works both in <a href="qgraphicsview.html#interactive-prop">interactive</a> and
137
non-interactive mode.</td>
140
<td class="topAlign"><tt>QGraphicsView.RubberBandDrag</tt></td>
141
<td class="topAlign"><tt>2</tt></td>
142
<td class="topAlign">A rubber band will appear. Dragging the mouse
143
will set the rubber band geometry, and all items covered by the
144
rubber band are selected. This mode is disabled for non-interactive
148
<p><b>See also</b> <a href="qgraphicsview.html#dragMode-prop">dragMode</a> and <a href="qgraphicsscene.html#setSelectionArea">QGraphicsScene.setSelectionArea</a>().</p>
151
<h3 class="fn"><a name="OptimizationFlag-enum" />QGraphicsView.OptimizationFlag</h3><p>This enum describes flags that you can enable to improve
152
rendering performance in <a href="qgraphicsview.html">QGraphicsView</a>. By default, none of these
153
flags are set. Note that setting a flag usually imposes a side
154
effect, and this effect can vary between paint devices and
156
<table class="valuelist">
157
<tr class="odd" valign="top">
158
<th class="tblConst">Constant</th>
159
<th class="tblval">Value</th>
160
<th class="tbldscr">Description</th>
163
<td class="topAlign"><tt>QGraphicsView.DontClipPainter</tt></td>
164
<td class="topAlign"><tt>0x1</tt></td>
165
<td class="topAlign">This value is obsolete and has no effect.</td>
168
<td class="topAlign">
169
<tt>QGraphicsView.DontSavePainterState</tt></td>
170
<td class="topAlign"><tt>0x2</tt></td>
171
<td class="topAlign">When rendering, <a href="qgraphicsview.html">QGraphicsView</a> protects the painter state
172
(see <a href="qpainter.html#save">QPainter.save</a>()) when
173
rendering the background or foreground, and when rendering each
174
item. This allows you to leave the painter in an altered state
175
(i.e., you can call <a href="qpainter.html#setPen">QPainter.setPen</a>() or <a href="qpainter.html#setBrush">QPainter.setBrush</a>() without restoring
176
the state after painting). However, if the items consistently do
177
restore the state, you should enable this flag to prevent <a href="qgraphicsview.html">QGraphicsView</a> from doing the same.</td>
180
<td class="topAlign">
181
<tt>QGraphicsView.DontAdjustForAntialiasing</tt></td>
182
<td class="topAlign"><tt>0x4</tt></td>
183
<td class="topAlign">Disables <a href="qgraphicsview.html">QGraphicsView</a>'s antialiasing
184
auto-adjustment of exposed areas. Items that render antialiased
185
lines on the boundaries of their <a href="qgraphicsitem.html#boundingRect">QGraphicsItem.boundingRect</a>()
186
can end up rendering parts of the line outside. To prevent
187
rendering artifacts, <a href="qgraphicsview.html">QGraphicsView</a>
188
expands all exposed regions by 2 pixels in all directions. If you
189
enable this flag, <a href="qgraphicsview.html">QGraphicsView</a>
190
will no longer perform these adjustments, minimizing the areas that
191
require redrawing, which improves performance. A common side effect
192
is that items that do draw with antialiasing can leave painting
193
traces behind on the scene as they are moved.</td>
196
<td class="topAlign"><tt>QGraphicsView.IndirectPainting</tt></td>
197
<td class="topAlign"><tt>0x8</tt></td>
198
<td class="topAlign">Since Qt 4.6, restore the old painting
199
algorithm that calls <a class="obsolete" href="qgraphicsview-obsolete.html#drawItems">QGraphicsView.drawItems</a>() and <a class="obsolete" href="qgraphicsscene-obsolete.html#drawItems">QGraphicsScene.drawItems</a>(). To be used only for
200
compatibility with old code.</td>
203
<p>This enum was introduced or modified in Qt 4.3.</p>
204
<p>The OptimizationFlags type is a typedef for <a href="qflags.html">QFlags</a><OptimizationFlag>. It stores an OR
205
combination of OptimizationFlag values.</p>
208
<h3 class="fn"><a name="ViewportAnchor-enum" />QGraphicsView.ViewportAnchor</h3><p>This enums describe the possible anchors that <a href="qgraphicsview.html">QGraphicsView</a> can use when the user
209
resizes the view or when the view is transformed.</p>
210
<table class="valuelist">
211
<tr class="odd" valign="top">
212
<th class="tblConst">Constant</th>
213
<th class="tblval">Value</th>
214
<th class="tbldscr">Description</th>
217
<td class="topAlign"><tt>QGraphicsView.NoAnchor</tt></td>
218
<td class="topAlign"><tt>0</tt></td>
219
<td class="topAlign">No anchor, i.e. the view leaves the scene's
220
position unchanged.</td>
223
<td class="topAlign"><tt>QGraphicsView.AnchorViewCenter</tt></td>
224
<td class="topAlign"><tt>1</tt></td>
225
<td class="topAlign">The scene point at the center of the view is
226
used as the anchor.</td>
229
<td class="topAlign"><tt>QGraphicsView.AnchorUnderMouse</tt></td>
230
<td class="topAlign"><tt>2</tt></td>
231
<td class="topAlign">The point under the mouse is used as the
235
<p><b>See also</b> <a href="qgraphicsview.html#resizeAnchor-prop">resizeAnchor</a> and
236
<a href="qgraphicsview.html#transformationAnchor-prop">transformationAnchor</a>.</p>
239
<h3 class="fn"><a name="ViewportUpdateMode-enum" />QGraphicsView.ViewportUpdateMode</h3><p>This enum describes how <a href="qgraphicsview.html">QGraphicsView</a> updates its viewport when
240
the scene contents change or are exposed.</p>
241
<table class="valuelist">
242
<tr class="odd" valign="top">
243
<th class="tblConst">Constant</th>
244
<th class="tblval">Value</th>
245
<th class="tbldscr">Description</th>
248
<td class="topAlign">
249
<tt>QGraphicsView.FullViewportUpdate</tt></td>
250
<td class="topAlign"><tt>0</tt></td>
251
<td class="topAlign">When any visible part of the scene changes or
252
is reexposed, <a href="qgraphicsview.html">QGraphicsView</a> will
253
update the entire viewport. This approach is fastest when <a href="qgraphicsview.html">QGraphicsView</a> spends more time figuring
254
out what to draw than it would spend drawing (e.g., when very many
255
small items are repeatedly updated). This is the preferred update
256
mode for viewports that do not support partial updates, such as
257
<a href="qglwidget.html">QGLWidget</a>, and for viewports that need
258
to disable scroll optimization.</td>
261
<td class="topAlign">
262
<tt>QGraphicsView.MinimalViewportUpdate</tt></td>
263
<td class="topAlign"><tt>1</tt></td>
264
<td class="topAlign"><a href="qgraphicsview.html">QGraphicsView</a>
265
will determine the minimal viewport region that requires a redraw,
266
minimizing the time spent drawing by avoiding a redraw of areas
267
that have not changed. This is <a href="qgraphicsview.html">QGraphicsView</a>'s default mode. Although
268
this approach provides the best performance in general, if there
269
are many small visible changes on the scene, <a href="qgraphicsview.html">QGraphicsView</a> might end up spending more
270
time finding the minimal approach than it will spend drawing.</td>
273
<td class="topAlign">
274
<tt>QGraphicsView.SmartViewportUpdate</tt></td>
275
<td class="topAlign"><tt>2</tt></td>
276
<td class="topAlign"><a href="qgraphicsview.html">QGraphicsView</a>
277
will attempt to find an optimal update mode by analyzing the areas
278
that require a redraw.</td>
281
<td class="topAlign">
282
<tt>QGraphicsView.BoundingRectViewportUpdate</tt></td>
283
<td class="topAlign"><tt>4</tt></td>
284
<td class="topAlign">The bounding rectangle of all changes in the
285
viewport will be redrawn. This mode has the advantage that <a href="qgraphicsview.html">QGraphicsView</a> searches only one region for
286
changes, minimizing time spent determining what needs redrawing.
287
The disadvantage is that areas that have not changed also need to
291
<td class="topAlign"><tt>QGraphicsView.NoViewportUpdate</tt></td>
292
<td class="topAlign"><tt>3</tt></td>
293
<td class="topAlign"><a href="qgraphicsview.html">QGraphicsView</a>
294
will never update its viewport when the scene changes; the user is
295
expected to control all updates. This mode disables all
296
(potentially slow) item visibility testing in <a href="qgraphicsview.html">QGraphicsView</a>, and is suitable for scenes
297
that either require a fixed frame rate, or where the viewport is
298
otherwise updated externally.</td>
301
<p>This enum was introduced or modified in Qt 4.3.</p>
302
<p><b>See also</b> <a href="qgraphicsview.html#viewportUpdateMode-prop">viewportUpdateMode</a>.</p>
303
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QGraphicsView" />QGraphicsView.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</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="qgraphicsview.html">QGraphicsView</a>.
304
<i>parent</i> is passed to <a href="qwidget.html">QWidget</a>'s
308
<h3 class="fn"><a name="QGraphicsView-2" />QGraphicsView.__init__ (<i>self</i>, <a href="qgraphicsscene.html">QGraphicsScene</a> <i>scene</i>, <a href="qwidget.html">QWidget</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="qgraphicsview.html">QGraphicsView</a> and
309
sets the visualized scene to <i>scene</i>. <i>parent</i> is passed
310
to <a href="qwidget.html">QWidget</a>'s constructor.</p>
313
<h3 class="fn"><a name="alignment" /><a href="qt-alignment.html">Qt.Alignment</a> QGraphicsView.alignment (<i>self</i>)</h3><h3 class="fn"><a name="backgroundBrush" /><a href="qbrush.html">QBrush</a> QGraphicsView.backgroundBrush (<i>self</i>)</h3><h3 class="fn"><a name="cacheMode" /><a href="qgraphicsview-cachemode.html">CacheMode</a> QGraphicsView.cacheMode (<i>self</i>)</h3><h3 class="fn"><a name="centerOn" />QGraphicsView.centerOn (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>pos</i>)</h3><p>Scrolls the contents of the viewport to ensure that the scene
314
coordinate <i>pos</i>, is centered in the view.</p>
315
<p>Because <i>pos</i> is a floating point coordinate, and the
316
scroll bars operate on integer coordinates, the centering is only
317
an approximation.</p>
318
<p><b>Note:</b> If the item is close to or outside the border, it
319
will be visible in the view, but not centered.</p>
320
<p><b>See also</b> <a href="qgraphicsview.html#ensureVisible">ensureVisible</a>().</p>
323
<h3 class="fn"><a name="centerOn-2" />QGraphicsView.centerOn (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a> <i>item</i>)</h3><p>This is an overloaded function.</p>
324
<p>This function is provided for convenience. It's equivalent to
325
calling centerOn(<a href="qpointf.html">QPointF</a>(<i>x</i>,
329
<h3 class="fn"><a name="centerOn-3" />QGraphicsView.centerOn (<i>self</i>, float <i>ax</i>, float <i>ay</i>)</h3><p>This is an overloaded function.</p>
330
<p>Scrolls the contents of the viewport to ensure that <i>item</i>
331
is centered in the view.</p>
332
<p><b>See also</b> <a href="qgraphicsview.html#ensureVisible">ensureVisible</a>().</p>
335
<h3 class="fn"><a name="contextMenuEvent" />QGraphicsView.contextMenuEvent (<i>self</i>, <a href="qcontextmenuevent.html">QContextMenuEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#contextMenuEvent">QWidget.contextMenuEvent</a>().</p>
338
<h3 class="fn"><a name="dragEnterEvent" />QGraphicsView.dragEnterEvent (<i>self</i>, <a href="qdragenterevent.html">QDragEnterEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#dragEnterEvent">QWidget.dragEnterEvent</a>().</p>
341
<h3 class="fn"><a name="dragLeaveEvent" />QGraphicsView.dragLeaveEvent (<i>self</i>, <a href="qdragleaveevent.html">QDragLeaveEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#dragLeaveEvent">QWidget.dragLeaveEvent</a>().</p>
344
<h3 class="fn"><a name="dragMode" /><a href="qgraphicsview.html#DragMode-enum">DragMode</a> QGraphicsView.dragMode (<i>self</i>)</h3><h3 class="fn"><a name="dragMoveEvent" />QGraphicsView.dragMoveEvent (<i>self</i>, <a href="qdragmoveevent.html">QDragMoveEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#dragMoveEvent">QWidget.dragMoveEvent</a>().</p>
347
<h3 class="fn"><a name="drawBackground" />QGraphicsView.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
348
any items and the foreground are drawn. Reimplement this function
349
to provide a custom background for this view.</p>
350
<p>If all you want is to define a color, texture or gradient for
351
the background, you can call <a href="qgraphicsview.html#backgroundBrush-prop">setBackgroundBrush</a>()
353
<p>All painting is done in <i>scene</i> coordinates. <i>rect</i> is
354
the exposed rectangle.</p>
355
<p>The default implementation fills <i>rect</i> using the view's
356
<a href="qgraphicsview.html#backgroundBrush-prop">backgroundBrush</a>. If
357
no such brush is defined (the default), the scene's
358
drawBackground() function is called instead.</p>
359
<p><b>See also</b> <a href="qgraphicsview.html#drawForeground">drawForeground</a>() and
360
<a href="qgraphicsscene.html#drawBackground">QGraphicsScene.drawBackground</a>().</p>
363
<h3 class="fn"><a name="drawForeground" />QGraphicsView.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
364
the background and all items are drawn. Reimplement this function
365
to provide a custom foreground for this view.</p>
366
<p>If all you want is to define a color, texture or gradient for
367
the foreground, you can call <a href="qgraphicsview.html#foregroundBrush-prop">setForegroundBrush</a>()
369
<p>All painting is done in <i>scene</i> coordinates. <i>rect</i> is
370
the exposed rectangle.</p>
371
<p>The default implementation fills <i>rect</i> using the view's
372
<a href="qgraphicsview.html#foregroundBrush-prop">foregroundBrush</a>. If
373
no such brush is defined (the default), the scene's
374
drawForeground() function is called instead.</p>
375
<p><b>See also</b> <a href="qgraphicsview.html#drawBackground">drawBackground</a>() and
376
<a href="qgraphicsscene.html#drawForeground">QGraphicsScene.drawForeground</a>().</p>
379
<h3 class="fn"><a name="drawItems" />QGraphicsView.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>)</h3><h3 class="fn"><a name="dropEvent" />QGraphicsView.dropEvent (<i>self</i>, <a href="qdropevent.html">QDropEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#dropEvent">QWidget.dropEvent</a>().</p>
382
<h3 class="fn"><a name="ensureVisible" />QGraphicsView.ensureVisible (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>, int <i>xMargin</i> = 50, int <i>yMargin</i> = 50)</h3><p>Scrolls the contents of the viewport so that the scene rectangle
383
<i>rect</i> is visible, with margins specified in pixels by
384
<i>xmargin</i> and <i>ymargin</i>. If the specified rect cannot be
385
reached, the contents are scrolled to the nearest valid position.
386
The default value for both margins is 50 pixels.</p>
387
<p><b>See also</b> <a href="qgraphicsview.html#centerOn">centerOn</a>().</p>
390
<h3 class="fn"><a name="ensureVisible-2" />QGraphicsView.ensureVisible (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a> <i>item</i>, int <i>xMargin</i> = 50, int <i>yMargin</i> = 50)</h3><p>This is an overloaded function.</p>
391
<p>This function is provided for convenience. It's equivalent to
392
calling ensureVisible(<a href="qrectf.html">QRectF</a>(<i>x</i>,
393
<i>y</i>, <i>w</i>, <i>h</i>), <i>xmargin</i>, <i>ymargin</i>).</p>
396
<h3 class="fn"><a name="ensureVisible-3" />QGraphicsView.ensureVisible (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, int <i>xMargin</i> = 50, int <i>yMargin</i> = 50)</h3><p>This is an overloaded function.</p>
397
<p>Scrolls the contents of the viewport so that the center of item
398
<i>item</i> is visible, with margins specified in pixels by
399
<i>xmargin</i> and <i>ymargin</i>. If the specified point cannot be
400
reached, the contents are scrolled to the nearest valid position.
401
The default value for both margins is 50 pixels.</p>
402
<p><b>See also</b> <a href="qgraphicsview.html#centerOn">centerOn</a>().</p>
405
<h3 class="fn"><a name="event" />bool QGraphicsView.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>
408
<h3 class="fn"><a name="fitInView" />QGraphicsView.fitInView (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>, <a href="qt.html#AspectRatioMode-enum">Qt.AspectRatioMode</a> <i>mode</i> = Qt.IgnoreAspectRatio)</h3><p>Scales the view matrix and scrolls the scroll bars to ensure
409
that the scene rectangle <i>rect</i> fits inside the viewport.
410
<i>rect</i> must be inside the scene rect; otherwise, fitInView()
411
cannot guarantee that the whole rect is visible.</p>
412
<p>This function keeps the view's rotation, translation, or shear.
413
The view is scaled according to <i>aspectRatioMode</i>. <i>rect</i>
414
will be centered in the view if it does not fit tightly.</p>
415
<p>It's common to call fitInView() from inside a reimplementation
416
of <a href="qgraphicsview.html#resizeEvent">resizeEvent</a>(), to
417
ensure that the whole scene, or parts of the scene, scales
418
automatically to fit the new size of the viewport as the view is
419
resized. Note though, that calling fitInView() from inside <a href="qgraphicsview.html#resizeEvent">resizeEvent</a>() can lead to
420
unwanted resize recursion, if the new transformation toggles the
421
automatic state of the scrollbars. You can toggle the scrollbar
422
policies to always on or always off to prevent this (see <a href="qabstractscrollarea.html#horizontalScrollBarPolicy-prop">horizontalScrollBarPolicy</a>()
423
and <a href="qabstractscrollarea.html#verticalScrollBarPolicy-prop">verticalScrollBarPolicy</a>()).</p>
424
<p>If <i>rect</i> is empty, or if the viewport is too small, this
425
function will do nothing.</p>
426
<p><b>See also</b> <a href="qgraphicsview.html#setTransform">setTransform</a>(), <a href="qgraphicsview.html#ensureVisible">ensureVisible</a>(), and
427
<a href="qgraphicsview.html#centerOn">centerOn</a>().</p>
430
<h3 class="fn"><a name="fitInView-2" />QGraphicsView.fitInView (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a> <i>item</i>, <a href="qt.html#AspectRatioMode-enum">Qt.AspectRatioMode</a> <i>mode</i> = Qt.IgnoreAspectRatio)</h3><p>This is an overloaded function.</p>
431
<p>This convenience function is equivalent to calling
432
fitInView(<a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>,
433
<i>w</i>, <i>h</i>), <i>aspectRatioMode</i>).</p>
434
<p><b>See also</b> <a href="qgraphicsview.html#ensureVisible">ensureVisible</a>() and <a href="qgraphicsview.html#centerOn">centerOn</a>().</p>
437
<h3 class="fn"><a name="fitInView-3" />QGraphicsView.fitInView (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, <a href="qt.html#AspectRatioMode-enum">Qt.AspectRatioMode</a> <i>mode</i> = Qt.IgnoreAspectRatio)</h3><p>This is an overloaded function.</p>
438
<p>Ensures that <i>item</i> fits tightly inside the view, scaling
439
the view according to <i>aspectRatioMode</i>.</p>
440
<p><b>See also</b> <a href="qgraphicsview.html#ensureVisible">ensureVisible</a>() and <a href="qgraphicsview.html#centerOn">centerOn</a>().</p>
443
<h3 class="fn"><a name="focusInEvent" />QGraphicsView.focusInEvent (<i>self</i>, <a href="qfocusevent.html">QFocusEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#focusInEvent">QWidget.focusInEvent</a>().</p>
446
<h3 class="fn"><a name="focusNextPrevChild" />bool QGraphicsView.focusNextPrevChild (<i>self</i>, bool <i>next</i>)</h3><p>Reimplemented from <a href="qwidget.html#focusNextPrevChild">QWidget.focusNextPrevChild</a>().</p>
449
<h3 class="fn"><a name="focusOutEvent" />QGraphicsView.focusOutEvent (<i>self</i>, <a href="qfocusevent.html">QFocusEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#focusOutEvent">QWidget.focusOutEvent</a>().</p>
452
<h3 class="fn"><a name="foregroundBrush" /><a href="qbrush.html">QBrush</a> QGraphicsView.foregroundBrush (<i>self</i>)</h3><h3 class="fn"><a name="inputMethodEvent" />QGraphicsView.inputMethodEvent (<i>self</i>, <a href="qinputmethodevent.html">QInputMethodEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#inputMethodEvent">QWidget.inputMethodEvent</a>().</p>
455
<h3 class="fn"><a name="inputMethodQuery" />QVariant QGraphicsView.inputMethodQuery (<i>self</i>, <a href="qt.html#InputMethodQuery-enum">Qt.InputMethodQuery</a> <i>query</i>)</h3><p>Reimplemented from <a href="qwidget.html#inputMethodQuery">QWidget.inputMethodQuery</a>().</p>
458
<h3 class="fn"><a name="invalidateScene" />QGraphicsView.invalidateScene (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i> = QRectF(), <a href="qgraphicsscene-scenelayers.html">QGraphicsScene.SceneLayers</a> <i>layers</i> = QGraphicsScene.AllLayers)</h3><p>This method is also a Qt slot with the C++ signature <tt>void invalidateScene(const QRectF& = QRectF(),QGraphicsScene::SceneLayers = QGraphicsScene.AllLayers)</tt>.</p><p>Invalidates and schedules a redraw of <i>layers</i> inside
459
<i>rect</i>. <i>rect</i> is in scene coordinates. Any cached
460
content for <i>layers</i> inside <i>rect</i> is unconditionally
461
invalidated and redrawn.</p>
462
<p>You can call this function to notify <a href="qgraphicsview.html">QGraphicsView</a> of changes to the background
463
or the foreground of the scene. It is commonly used for scenes with
464
tile-based backgrounds to notify changes when <a href="qgraphicsview.html">QGraphicsView</a> has enabled background
466
<p>Note that <a href="qgraphicsview.html">QGraphicsView</a>
467
currently supports background caching only (see <a href="qgraphicsview.html#CacheModeFlag-enum">QGraphicsView.CacheBackground</a>).
468
This function is equivalent to calling <a href="qwidget.html#update">update</a>() if any layer but <a href="qgraphicsscene.html#SceneLayer-enum">QGraphicsScene.BackgroundLayer</a>
470
<p><b>See also</b> <a href="qgraphicsscene.html#invalidate">QGraphicsScene.invalidate</a>()
471
and <a href="qwidget.html#update">update</a>().</p>
474
<h3 class="fn"><a name="isInteractive" />bool QGraphicsView.isInteractive (<i>self</i>)</h3><h3 class="fn"><a name="isTransformed" />bool QGraphicsView.isTransformed (<i>self</i>)</h3><p>Returns true if the view is transformed (i.e., a non-identity
475
transform has been assigned, or the scrollbars are adjusted).</p>
476
<p>This function was introduced in Qt 4.6.</p>
477
<p><b>See also</b> <a href="qgraphicsview.html#setTransform">setTransform</a>(), <a href="qabstractscrollarea.html#horizontalScrollBar">horizontalScrollBar</a>(),
478
and <a href="qabstractscrollarea.html#verticalScrollBar">verticalScrollBar</a>().</p>
481
<h3 class="fn"><a name="itemAt" /><a href="qgraphicsitem.html">QGraphicsItem</a> QGraphicsView.itemAt (<i>self</i>, <a href="qpoint.html">QPoint</a> <i>pos</i>)</h3><p>Returns the item at position <i>pos</i>, which is in viewport
482
coordinates. If there are several items at this position, this
483
function returns the topmost item.</p>
486
<span class="type">void</span> CustomView<span class="operator">.</span>mousePressEvent(<span class="type"><a href="qmouseevent.html">QMouseEvent</a></span> <span class="operator">*</span>event)
488
<span class="keyword">if</span> (<span class="type"><a href="qgraphicsitem.html">QGraphicsItem</a></span> <span class="operator">*</span>item <span class="operator">=</span> itemAt(event<span class="operator">-</span><span class="operator">></span>pos())) {
489
<a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"You clicked on item"</span> <span class="operator"><</span><span class="operator"><</span> item;
490
} <span class="keyword">else</span> {
491
<a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"You didn't click on an item."</span>;
495
<p><b>See also</b> <a href="qgraphicsview.html#items">items</a>()
496
and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p>
499
<h3 class="fn"><a name="itemAt-2" /><a href="qgraphicsitem.html">QGraphicsItem</a> QGraphicsView.itemAt (<i>self</i>, int <i>ax</i>, int <i>ay</i>)</h3><p>This is an overloaded function.</p>
500
<p>This function is provided for convenience. It's equivalent to
501
calling itemAt(<a href="qpoint.html">QPoint</a>(<i>x</i>,
505
<h3 class="fn"><a name="items" />list-of-QGraphicsItem QGraphicsView.items (<i>self</i>)</h3><p>Returns a list of all the items in the associated scene, in
506
descending stacking order (i.e., the first item in the returned
507
list is the uppermost item).</p>
508
<p><b>See also</b> <a href="qgraphicsscene.html#items">QGraphicsScene.items</a>() and
509
<a href="qgraphicsitem.html#sorting">Sorting</a>.</p>
512
<h3 class="fn"><a name="items-2" />list-of-QGraphicsItem QGraphicsView.items (<i>self</i>, <a href="qpoint.html">QPoint</a> <i>pos</i>)</h3><p>Returns a list of all the items at the position <i>pos</i> in
513
the view. The items are listed in descending stacking order (i.e.,
514
the first item in the list is the uppermost item, and the last item
515
is the lowermost item). <i>pos</i> is in viewport coordinates.</p>
516
<p>This function is most commonly called from within mouse event
517
handlers in a subclass in <a href="qgraphicsview.html">QGraphicsView</a>. <i>pos</i> is in
518
untransformed viewport coordinates, just like <a href="qmouseevent.html#pos">QMouseEvent.pos</a>().</p>
520
<span class="type">void</span> CustomView<span class="operator">.</span>mousePressEvent(<span class="type"><a href="qmouseevent.html">QMouseEvent</a></span> <span class="operator">*</span>event)
522
<a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"There are"</span> <span class="operator"><</span><span class="operator"><</span> items(event<span class="operator">-</span><span class="operator">></span>pos())<span class="operator">.</span>size()
523
<span class="operator"><</span><span class="operator"><</span> <span class="string">"items at position"</span> <span class="operator"><</span><span class="operator"><</span> mapToScene(event<span class="operator">-</span><span class="operator">></span>pos());
526
<p><b>See also</b> <a href="qgraphicsscene.html#items">QGraphicsScene.items</a>() and
527
<a href="qgraphicsitem.html#sorting">Sorting</a>.</p>
530
<h3 class="fn"><a name="items-3" />list-of-QGraphicsItem QGraphicsView.items (<i>self</i>, int <i>ax</i>, int <i>ay</i>)</h3><p>This function is provided for convenience. It's equivalent to
531
calling items(<a href="qpoint.html">QPoint</a>(<i>x</i>,
535
<h3 class="fn"><a name="items-4" />list-of-QGraphicsItem QGraphicsView.items (<i>self</i>, int <i>x</i>, int <i>y</i>, int <i>w</i>, int <i>h</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i> = Qt.IntersectsItemShape)</h3><p>This convenience function is equivalent to calling
536
items(<a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>,
537
<i>w</i>, <i>h</i>), <i>mode</i>).</p>
538
<p>This function was introduced in Qt 4.3.</p>
541
<h3 class="fn"><a name="items-5" />list-of-QGraphicsItem QGraphicsView.items (<i>self</i>, <a href="qrect.html">QRect</a> <i>rect</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i> = Qt.IntersectsItemShape)</h3><p>This is an overloaded function.</p>
542
<p>Returns a list of all the items that, depending on <i>mode</i>,
543
are either contained by or intersect with <i>rect</i>. <i>rect</i>
544
is in viewport coordinates.</p>
545
<p>The default value for <i>mode</i> is <a href="qt.html#ItemSelectionMode-enum">Qt.IntersectsItemShape</a>; all
546
items whose exact shape intersects with or is contained by
547
<i>rect</i> are returned.</p>
548
<p>The items are sorted in descending stacking order (i.e., the
549
first item in the returned list is the uppermost item).</p>
550
<p><b>See also</b> <a href="qgraphicsview.html#itemAt">itemAt</a>(), <a href="qgraphicsview.html#items">items</a>(), <a href="qgraphicsview.html#mapToScene">mapToScene</a>(), and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p>
553
<h3 class="fn"><a name="items-6" />list-of-QGraphicsItem QGraphicsView.items (<i>self</i>, <a href="qpolygon.html">QPolygon</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>
554
<p>Returns a list of all the items that, depending on <i>mode</i>,
555
are either contained by or intersect with <i>polygon</i>.
556
<i>polygon</i> is in viewport coordinates.</p>
557
<p>The default value for <i>mode</i> is <a href="qt.html#ItemSelectionMode-enum">Qt.IntersectsItemShape</a>; all
558
items whose exact shape intersects with or is contained by
559
<i>polygon</i> are returned.</p>
560
<p>The items are sorted by descending stacking order (i.e., the
561
first item in the returned list is the uppermost item).</p>
562
<p><b>See also</b> <a href="qgraphicsview.html#itemAt">itemAt</a>(), <a href="qgraphicsview.html#items">items</a>(), <a href="qgraphicsview.html#mapToScene">mapToScene</a>(), and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p>
565
<h3 class="fn"><a name="items-7" />list-of-QGraphicsItem QGraphicsView.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><p>This is an overloaded function.</p>
566
<p>Returns a list of all the items that, depending on <i>mode</i>,
567
are either contained by or intersect with <i>path</i>. <i>path</i>
568
is in viewport coordinates.</p>
569
<p>The default value for <i>mode</i> is <a href="qt.html#ItemSelectionMode-enum">Qt.IntersectsItemShape</a>; all
570
items whose exact shape intersects with or is contained by
571
<i>path</i> are returned.</p>
572
<p><b>See also</b> <a href="qgraphicsview.html#itemAt">itemAt</a>(), <a href="qgraphicsview.html#items">items</a>(), <a href="qgraphicsview.html#mapToScene">mapToScene</a>(), and <a href="qgraphicsitem.html#sorting">Sorting</a>.</p>
575
<h3 class="fn"><a name="keyPressEvent" />QGraphicsView.keyPressEvent (<i>self</i>, <a href="qkeyevent.html">QKeyEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#keyPressEvent">QWidget.keyPressEvent</a>().</p>
578
<h3 class="fn"><a name="keyReleaseEvent" />QGraphicsView.keyReleaseEvent (<i>self</i>, <a href="qkeyevent.html">QKeyEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#keyReleaseEvent">QWidget.keyReleaseEvent</a>().</p>
581
<h3 class="fn"><a name="mapFromScene" /><a href="qpoint.html">QPoint</a> QGraphicsView.mapFromScene (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>point</i>)</h3><p>Returns the scene coordinate <i>point</i> to viewport
583
<p><b>See also</b> <a href="qgraphicsview.html#mapToScene">mapToScene</a>().</p>
586
<h3 class="fn"><a name="mapFromScene-2" /><a href="qpolygon.html">QPolygon</a> QGraphicsView.mapFromScene (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>)</h3><p>Returns the scene rectangle <i>rect</i> to a viewport coordinate
588
<p><b>See also</b> <a href="qgraphicsview.html#mapToScene">mapToScene</a>().</p>
591
<h3 class="fn"><a name="mapFromScene-3" /><a href="qpolygon.html">QPolygon</a> QGraphicsView.mapFromScene (<i>self</i>, <a href="qpolygonf.html">QPolygonF</a> <i>polygon</i>)</h3><p>Returns the scene coordinate polygon <i>polygon</i> to a
592
viewport coordinate polygon.</p>
593
<p><b>See also</b> <a href="qgraphicsview.html#mapToScene">mapToScene</a>().</p>
596
<h3 class="fn"><a name="mapFromScene-4" /><a href="qpainterpath.html">QPainterPath</a> QGraphicsView.mapFromScene (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>path</i>)</h3><p>Returns the scene coordinate painter path <i>path</i> to a
597
viewport coordinate painter path.</p>
598
<p><b>See also</b> <a href="qgraphicsview.html#mapToScene">mapToScene</a>().</p>
601
<h3 class="fn"><a name="mapFromScene-5" /><a href="qpoint.html">QPoint</a> QGraphicsView.mapFromScene (<i>self</i>, float <i>ax</i>, float <i>ay</i>)</h3><p>This function is provided for convenience. It's equivalent to
602
calling mapFromScene(<a href="qpointf.html">QPointF</a>(<i>x</i>,
606
<h3 class="fn"><a name="mapFromScene-6" /><a href="qpolygon.html">QPolygon</a> QGraphicsView.mapFromScene (<i>self</i>, float <i>ax</i>, float <i>ay</i>, float <i>w</i>, float <i>h</i>)</h3><p>This function is provided for convenience. It's equivalent to
607
calling mapFromScene(<a href="qrectf.html">QRectF</a>(<i>x</i>,
608
<i>y</i>, <i>w</i>, <i>h</i>)).</p>
611
<h3 class="fn"><a name="mapToScene" /><a href="qpointf.html">QPointF</a> QGraphicsView.mapToScene (<i>self</i>, <a href="qpoint.html">QPoint</a> <i>point</i>)</h3><p>Returns the viewport coordinate <i>point</i> mapped to scene
613
<p>Note: It can be useful to map the whole rectangle covered by the
614
pixel at <i>point</i> instead of the point itself. To do this, you
615
can call mapToScene(<a href="qrect.html">QRect</a>(<i>point</i>,
616
<a href="qsize.html">QSize</a>(2, 2))).</p>
617
<p><b>See also</b> <a href="qgraphicsview.html#mapFromScene">mapFromScene</a>().</p>
620
<h3 class="fn"><a name="mapToScene-2" /><a href="qpolygonf.html">QPolygonF</a> QGraphicsView.mapToScene (<i>self</i>, <a href="qrect.html">QRect</a> <i>rect</i>)</h3><p>Returns the viewport rectangle <i>rect</i> mapped to a scene
621
coordinate polygon.</p>
622
<p><b>See also</b> <a href="qgraphicsview.html#mapFromScene">mapFromScene</a>().</p>
625
<h3 class="fn"><a name="mapToScene-3" /><a href="qpolygonf.html">QPolygonF</a> QGraphicsView.mapToScene (<i>self</i>, <a href="qpolygon.html">QPolygon</a> <i>polygon</i>)</h3><p>Returns the viewport polygon <i>polygon</i> mapped to a scene
626
coordinate polygon.</p>
627
<p><b>See also</b> <a href="qgraphicsview.html#mapFromScene">mapFromScene</a>().</p>
630
<h3 class="fn"><a name="mapToScene-4" /><a href="qpainterpath.html">QPainterPath</a> QGraphicsView.mapToScene (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>path</i>)</h3><p>Returns the viewport painter path <i>path</i> mapped to a scene
631
coordinate painter path.</p>
632
<p><b>See also</b> <a href="qgraphicsview.html#mapFromScene">mapFromScene</a>().</p>
635
<h3 class="fn"><a name="mapToScene-5" /><a href="qpointf.html">QPointF</a> QGraphicsView.mapToScene (<i>self</i>, int <i>ax</i>, int <i>ay</i>)</h3><p>This function is provided for convenience. It's equivalent to
636
calling mapToScene(<a href="qpoint.html">QPoint</a>(<i>x</i>,
640
<h3 class="fn"><a name="mapToScene-6" /><a href="qpolygonf.html">QPolygonF</a> QGraphicsView.mapToScene (<i>self</i>, int <i>ax</i>, int <i>ay</i>, int <i>w</i>, int <i>h</i>)</h3><p>This function is provided for convenience. It's equivalent to
641
calling mapToScene(<a href="qrect.html">QRect</a>(<i>x</i>,
642
<i>y</i>, <i>w</i>, <i>h</i>)).</p>
645
<h3 class="fn"><a name="matrix" /><a href="qmatrix.html">QMatrix</a> QGraphicsView.matrix (<i>self</i>)</h3><p>Returns the current transformation matrix for the view. If no
646
current transformation is set, the identity matrix is returned.</p>
647
<p><b>See also</b> <a href="qgraphicsview.html#setMatrix">setMatrix</a>(), <a href="qgraphicsview.html#transform">transform</a>(), <a href="qgraphicsview.html#rotate">rotate</a>(), <a href="qgraphicsview.html#scale">scale</a>(), <a href="qgraphicsview.html#shear">shear</a>(), and <a href="qgraphicsview.html#translate">translate</a>().</p>
650
<h3 class="fn"><a name="mouseDoubleClickEvent" />QGraphicsView.mouseDoubleClickEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#mouseDoubleClickEvent">QWidget.mouseDoubleClickEvent</a>().</p>
653
<h3 class="fn"><a name="mouseMoveEvent" />QGraphicsView.mouseMoveEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#mouseMoveEvent">QWidget.mouseMoveEvent</a>().</p>
656
<h3 class="fn"><a name="mousePressEvent" />QGraphicsView.mousePressEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#mousePressEvent">QWidget.mousePressEvent</a>().</p>
659
<h3 class="fn"><a name="mouseReleaseEvent" />QGraphicsView.mouseReleaseEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#mouseReleaseEvent">QWidget.mouseReleaseEvent</a>().</p>
662
<h3 class="fn"><a name="optimizationFlags" /><a href="qgraphicsview-optimizationflags.html">OptimizationFlags</a> QGraphicsView.optimizationFlags (<i>self</i>)</h3><h3 class="fn"><a name="paintEvent" />QGraphicsView.paintEvent (<i>self</i>, <a href="qpaintevent.html">QPaintEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#paintEvent">QWidget.paintEvent</a>().</p>
665
<h3 class="fn"><a name="render" />QGraphicsView.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="qrect.html">QRect</a> <i>source</i> = QRect(), <a href="qt.html#AspectRatioMode-enum">Qt.AspectRatioMode</a> <i>mode</i> = Qt.KeepAspectRatio)</h3><p>Renders the <i>source</i> rect, which is in view coordinates,
666
from the scene into <i>target</i>, which is in paint device
667
coordinates, using <i>painter</i>. This function is useful for
668
capturing the contents of the view onto a paint device, such as a
669
<a href="qimage.html">QImage</a> (e.g., to take a screenshot), or
670
for printing to <a href="qprinter.html">QPrinter</a>. For
673
<span class="type"><a href="qgraphicsscene.html">QGraphicsScene</a></span> scene;
674
scene<span class="operator">.</span>addItem(<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
675
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
677
<span class="type"><a href="qgraphicsview.html">QGraphicsView</a></span> view(<span class="operator">&</span>scene);
678
view<span class="operator">.</span>show();
679
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
681
<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);
682
printer<span class="operator">.</span>setPageSize(<span class="type"><a href="qprinter.html">QPrinter</a></span><span class="operator">.</span>A4);
683
<span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="operator">&</span>printer);
685
<span class="comment">// print, fitting the viewport contents into a full page</span>
686
view<span class="operator">.</span>render(<span class="operator">&</span>painter);
688
<span class="comment">// print the upper half of the viewport into the lower.</span>
689
<span class="comment">// half of the page.</span>
690
<span class="type"><a href="qrect.html">QRect</a></span> viewport <span class="operator">=</span> view<span class="operator">.</span>viewport()<span class="operator">-</span><span class="operator">></span>rect();
691
view<span class="operator">.</span>render(<span class="operator">&</span>painter<span class="operator">,</span>
692
<span class="type"><a href="qrectf.html">QRectF</a></span>(<span class="number">0</span><span class="operator">,</span> printer<span class="operator">.</span>height() <span class="operator">/</span> <span class="number">2</span><span class="operator">,</span>
693
printer<span class="operator">.</span>width()<span class="operator">,</span> printer<span class="operator">.</span>height() <span class="operator">/</span> <span class="number">2</span>)<span class="operator">,</span>
694
viewport<span class="operator">.</span>adjusted(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="operator">-</span>viewport<span class="operator">.</span>height() <span class="operator">/</span> <span class="number">2</span>));
696
<p>If <i>source</i> is a null rect, this function will use <a href="qabstractscrollarea.html#viewport">viewport</a>()-><a href="qwidget.html#rect-prop">rect</a>() to determine what to draw. If
697
<i>target</i> is a null rect, the full dimensions of
698
<i>painter</i>'s paint device (e.g., for a <a href="qprinter.html">QPrinter</a>, the page size) will be used.</p>
699
<p>The source rect contents will be transformed according to
700
<i>aspectRatioMode</i> to fit into the target rect. By default, the
701
aspect ratio is kept, and <i>source</i> is scaled to fit in
703
<p><b>See also</b> <a href="qgraphicsscene.html#render">QGraphicsScene.render</a>().</p>
706
<h3 class="fn"><a name="renderHints" /><a href="qpainter-renderhints.html">QPainter.RenderHints</a> QGraphicsView.renderHints (<i>self</i>)</h3><h3 class="fn"><a name="resetCachedContent" />QGraphicsView.resetCachedContent (<i>self</i>)</h3><p>Resets any cached content. Calling this function will clear
707
<a href="qgraphicsview.html">QGraphicsView</a>'s cache. If the
708
current cache mode is <a href="qgraphicsview.html#CacheModeFlag-enum">CacheNone</a>, this
709
function does nothing.</p>
710
<p>This function is called automatically for you when the <a href="qgraphicsview.html#backgroundBrush-prop">backgroundBrush</a> or
711
<a href="qgraphicsscene.html#backgroundBrush-prop">QGraphicsScene.backgroundBrush</a>
712
properties change; you only need to call this function if you have
713
reimplemented <a href="qgraphicsscene.html#drawBackground">QGraphicsScene.drawBackground</a>()
714
or <a href="qgraphicsview.html#drawBackground">QGraphicsView.drawBackground</a>()
715
to draw a custom background, and need to trigger a full redraw.</p>
716
<p><b>See also</b> <a href="qgraphicsview.html#cacheMode-prop">cacheMode</a>().</p>
719
<h3 class="fn"><a name="resetMatrix" />QGraphicsView.resetMatrix (<i>self</i>)</h3><p>Resets the view transformation matrix to the identity
721
<p><b>See also</b> <a href="qgraphicsview.html#resetTransform">resetTransform</a>().</p>
724
<h3 class="fn"><a name="resetTransform" />QGraphicsView.resetTransform (<i>self</i>)</h3><p>Resets the view transformation to the identity matrix.</p>
725
<p><b>See also</b> <a href="qgraphicsview.html#transform">transform</a>() and <a href="qgraphicsview.html#setTransform">setTransform</a>().</p>
728
<h3 class="fn"><a name="resizeAnchor" /><a href="qgraphicsview.html#ViewportAnchor-enum">ViewportAnchor</a> QGraphicsView.resizeAnchor (<i>self</i>)</h3><h3 class="fn"><a name="resizeEvent" />QGraphicsView.resizeEvent (<i>self</i>, <a href="qresizeevent.html">QResizeEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#resizeEvent">QWidget.resizeEvent</a>().</p>
731
<h3 class="fn"><a name="rotate" />QGraphicsView.rotate (<i>self</i>, float <i>angle</i>)</h3><p>Rotates the current view transformation <i>angle</i> degrees
733
<p><b>See also</b> <a href="qgraphicsview.html#setTransform">setTransform</a>(), <a href="qgraphicsview.html#transform">transform</a>(), <a href="qgraphicsview.html#scale">scale</a>(), <a href="qgraphicsview.html#shear">shear</a>(), and <a href="qgraphicsview.html#translate">translate</a>().</p>
736
<h3 class="fn"><a name="rubberBandSelectionMode" /><a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> QGraphicsView.rubberBandSelectionMode (<i>self</i>)</h3><h3 class="fn"><a name="scale" />QGraphicsView.scale (<i>self</i>, float <i>sx</i>, float <i>sy</i>)</h3><p>Scales the current view transformation by (<i>sx</i>,
738
<p><b>See also</b> <a href="qgraphicsview.html#setTransform">setTransform</a>(), <a href="qgraphicsview.html#transform">transform</a>(), <a href="qgraphicsview.html#rotate">rotate</a>(), <a href="qgraphicsview.html#shear">shear</a>(), and <a href="qgraphicsview.html#translate">translate</a>().</p>
741
<h3 class="fn"><a name="scene" /><a href="qgraphicsscene.html">QGraphicsScene</a> QGraphicsView.scene (<i>self</i>)</h3><p>Returns a pointer to the scene that is currently visualized in
742
the view. If no scene is currently visualized, 0 is returned.</p>
743
<p><b>See also</b> <a href="qgraphicsview.html#setScene">setScene</a>().</p>
746
<h3 class="fn"><a name="sceneRect" /><a href="qrectf.html">QRectF</a> QGraphicsView.sceneRect (<i>self</i>)</h3><h3 class="fn"><a name="scrollContentsBy" />QGraphicsView.scrollContentsBy (<i>self</i>, int <i>dx</i>, int <i>dy</i>)</h3><p>Reimplemented from <a href="qabstractscrollarea.html#scrollContentsBy">QAbstractScrollArea.scrollContentsBy</a>().</p>
749
<h3 class="fn"><a name="setAlignment" />QGraphicsView.setAlignment (<i>self</i>, <a href="qt-alignment.html">Qt.Alignment</a> <i>alignment</i>)</h3><h3 class="fn"><a name="setBackgroundBrush" />QGraphicsView.setBackgroundBrush (<i>self</i>, <a href="qbrush.html">QBrush</a> <i>brush</i>)</h3><h3 class="fn"><a name="setCacheMode" />QGraphicsView.setCacheMode (<i>self</i>, <a href="qgraphicsview-cachemode.html">CacheMode</a> <i>mode</i>)</h3><h3 class="fn"><a name="setDragMode" />QGraphicsView.setDragMode (<i>self</i>, <a href="qgraphicsview.html#DragMode-enum">DragMode</a> <i>mode</i>)</h3><h3 class="fn"><a name="setForegroundBrush" />QGraphicsView.setForegroundBrush (<i>self</i>, <a href="qbrush.html">QBrush</a> <i>brush</i>)</h3><h3 class="fn"><a name="setInteractive" />QGraphicsView.setInteractive (<i>self</i>, bool <i>allowed</i>)</h3><h3 class="fn"><a name="setMatrix" />QGraphicsView.setMatrix (<i>self</i>, <a href="qmatrix.html">QMatrix</a> <i>matrix</i>, bool <i>combine</i> = False)</h3><p>Sets the view's current transformation matrix to
751
<p>If <i>combine</i> is true, then <i>matrix</i> is combined with
752
the current matrix; otherwise, <i>matrix</i> <i>replaces</i> the
753
current matrix. <i>combine</i> is false by default.</p>
754
<p>The transformation matrix tranforms the scene into view
755
coordinates. Using the default transformation, provided by the
756
identity matrix, one pixel in the view represents one unit in the
757
scene (e.g., a 10x10 rectangular item is drawn using 10x10 pixels
758
in the view). If a 2x2 scaling matrix is applied, the scene will be
759
drawn in 1:2 (e.g., a 10x10 rectangular item is then drawn using
760
20x20 pixels in the view).</p>
763
<span class="type"><a href="qgraphicsscene.html">QGraphicsScene</a></span> scene;
764
scene<span class="operator">.</span>addText(<span class="string">"GraphicsView rotated clockwise"</span>);
766
<span class="type"><a href="qgraphicsview.html">QGraphicsView</a></span> view(<span class="operator">&</span>scene);
767
view<span class="operator">.</span><a href="qgraphicsview.html#rotate">rotate</a>(<span class="number">90</span>); <span class="comment">// the text is rendered with a 90 degree clockwise rotation</span>
768
view<span class="operator">.</span><a href="qwidget.html#show">show</a>();
770
<p>To simplify interation with items using a transformed view,
771
<a href="qgraphicsview.html">QGraphicsView</a> provides mapTo...
772
and mapFrom... functions that can translate between scene and view
773
coordinates. For example, you can call <a href="qgraphicsview.html#mapToScene">mapToScene</a>() to map a view
774
coordinate to a floating point scene coordinate, or <a href="qgraphicsview.html#mapFromScene">mapFromScene</a>() to map from
775
floating point scene coordinates to view coordinates.</p>
776
<p><b>See also</b> <a href="qgraphicsview.html#matrix">matrix</a>(), <a href="qgraphicsview.html#setTransform">setTransform</a>(), <a href="qgraphicsview.html#rotate">rotate</a>(), <a href="qgraphicsview.html#scale">scale</a>(), <a href="qgraphicsview.html#shear">shear</a>(), and <a href="qgraphicsview.html#translate">translate</a>().</p>
779
<h3 class="fn"><a name="setOptimizationFlag" />QGraphicsView.setOptimizationFlag (<i>self</i>, <a href="qgraphicsview.html#OptimizationFlag-enum">OptimizationFlag</a> <i>flag</i>, bool <i>enabled</i> = True)</h3><p>Enables <i>flag</i> if <i>enabled</i> is true; otherwise
780
disables <i>flag</i>.</p>
781
<p><b>See also</b> <a href="qgraphicsview.html#optimizationFlags-prop">optimizationFlags</a>.</p>
784
<h3 class="fn"><a name="setOptimizationFlags" />QGraphicsView.setOptimizationFlags (<i>self</i>, <a href="qgraphicsview-optimizationflags.html">OptimizationFlags</a> <i>flags</i>)</h3><h3 class="fn"><a name="setRenderHint" />QGraphicsView.setRenderHint (<i>self</i>, <a href="qpainter.html#RenderHint-enum">QPainter.RenderHint</a> <i>hint</i>, bool <i>on</i> = True)</h3><p>If <i>enabled</i> is true, the render hint <i>hint</i> is
785
enabled; otherwise it is disabled.</p>
786
<p><b>See also</b> <a href="qgraphicsview.html#renderHints-prop">renderHints</a>.</p>
789
<h3 class="fn"><a name="setRenderHints" />QGraphicsView.setRenderHints (<i>self</i>, <a href="qpainter-renderhints.html">QPainter.RenderHints</a> <i>hints</i>)</h3><h3 class="fn"><a name="setResizeAnchor" />QGraphicsView.setResizeAnchor (<i>self</i>, <a href="qgraphicsview.html#ViewportAnchor-enum">ViewportAnchor</a> <i>anchor</i>)</h3><h3 class="fn"><a name="setRubberBandSelectionMode" />QGraphicsView.setRubberBandSelectionMode (<i>self</i>, <a href="qt.html#ItemSelectionMode-enum">Qt.ItemSelectionMode</a> <i>mode</i>)</h3><h3 class="fn"><a name="setScene" />QGraphicsView.setScene (<i>self</i>, <a href="qgraphicsscene.html">QGraphicsScene</a> <i>scene</i>)</h3><p>Sets the current scene to <i>scene</i>. If <i>scene</i> is
790
already being viewed, this function does nothing.</p>
791
<p>When a scene is set on a view, the <a href="qgraphicsscene.html#changed">QGraphicsScene.changed</a>() signal
792
is automatically connected to this view's <a href="qgraphicsview.html#updateScene">updateScene</a>() slot, and the
793
view's scroll bars are adjusted to fit the size of the scene.</p>
794
<p><b>See also</b> <a href="qgraphicsview.html#scene">scene</a>().</p>
797
<h3 class="fn"><a name="setSceneRect" />QGraphicsView.setSceneRect (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>)</h3><h3 class="fn"><a name="setSceneRect-2" />QGraphicsView.setSceneRect (<i>self</i>, float <i>ax</i>, float <i>ay</i>, float <i>aw</i>, float <i>ah</i>)</h3><h3 class="fn"><a name="setTransform" />QGraphicsView.setTransform (<i>self</i>, <a href="qtransform.html">QTransform</a> <i>matrix</i>, bool <i>combine</i> = False)</h3><p>Sets the view's current transformation matrix to
799
<p>If <i>combine</i> is true, then <i>matrix</i> is combined with
800
the current matrix; otherwise, <i>matrix</i> <i>replaces</i> the
801
current matrix. <i>combine</i> is false by default.</p>
802
<p>The transformation matrix tranforms the scene into view
803
coordinates. Using the default transformation, provided by the
804
identity matrix, one pixel in the view represents one unit in the
805
scene (e.g., a 10x10 rectangular item is drawn using 10x10 pixels
806
in the view). If a 2x2 scaling matrix is applied, the scene will be
807
drawn in 1:2 (e.g., a 10x10 rectangular item is then drawn using
808
20x20 pixels in the view).</p>
811
<span class="type"><a href="qgraphicsscene.html">QGraphicsScene</a></span> scene;
812
scene<span class="operator">.</span>addText(<span class="string">"GraphicsView rotated clockwise"</span>);
814
<span class="type"><a href="qgraphicsview.html">QGraphicsView</a></span> view(<span class="operator">&</span>scene);
815
view<span class="operator">.</span>rotate(<span class="number">90</span>); <span class="comment">// the text is rendered with a 90 degree clockwise rotation</span>
816
view<span class="operator">.</span>show();
818
<p>To simplify interation with items using a transformed view,
819
<a href="qgraphicsview.html">QGraphicsView</a> provides mapTo...
820
and mapFrom... functions that can translate between scene and view
821
coordinates. For example, you can call <a href="qgraphicsview.html#mapToScene">mapToScene</a>() to map a view
822
coordiate to a floating point scene coordinate, or <a href="qgraphicsview.html#mapFromScene">mapFromScene</a>() to map from
823
floating point scene coordinates to view coordinates.</p>
824
<p><b>See also</b> <a href="qgraphicsview.html#transform">transform</a>(), <a href="qgraphicsview.html#rotate">rotate</a>(), <a href="qgraphicsview.html#scale">scale</a>(), <a href="qgraphicsview.html#shear">shear</a>(), and <a href="qgraphicsview.html#translate">translate</a>().</p>
827
<h3 class="fn"><a name="setTransformationAnchor" />QGraphicsView.setTransformationAnchor (<i>self</i>, <a href="qgraphicsview.html#ViewportAnchor-enum">ViewportAnchor</a> <i>anchor</i>)</h3><h3 class="fn"><a name="setupViewport" />QGraphicsView.setupViewport (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>widget</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setupViewport(QWidget *)</tt>.</p><p>This slot is called by <a href="qabstractscrollarea.html">QAbstractScrollArea</a> after <a href="qabstractscrollarea.html#setViewport">setViewport</a>() has been
828
called. Reimplement this function in a subclass of <a href="qgraphicsview.html">QGraphicsView</a> to initialize the new
829
viewport <i>widget</i> before it is used.</p>
830
<p><b>See also</b> <a href="qabstractscrollarea.html#setViewport">setViewport</a>().</p>
833
<h3 class="fn"><a name="setViewportUpdateMode" />QGraphicsView.setViewportUpdateMode (<i>self</i>, <a href="qgraphicsview.html#ViewportUpdateMode-enum">ViewportUpdateMode</a> <i>mode</i>)</h3><h3 class="fn"><a name="shear" />QGraphicsView.shear (<i>self</i>, float <i>sh</i>, float <i>sv</i>)</h3><p>Shears the current view transformation by (<i>sh</i>,
835
<p><b>See also</b> <a href="qgraphicsview.html#setTransform">setTransform</a>(), <a href="qgraphicsview.html#transform">transform</a>(), <a href="qgraphicsview.html#rotate">rotate</a>(), <a href="qgraphicsview.html#scale">scale</a>(), and <a href="qgraphicsview.html#translate">translate</a>().</p>
838
<h3 class="fn"><a name="showEvent" />QGraphicsView.showEvent (<i>self</i>, <a href="qshowevent.html">QShowEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#showEvent">QWidget.showEvent</a>().</p>
841
<h3 class="fn"><a name="sizeHint" /><a href="qsize.html">QSize</a> QGraphicsView.sizeHint (<i>self</i>)</h3><p>Reimplemented from <a href="qwidget.html#sizeHint-prop">QWidget.sizeHint</a>().</p>
844
<h3 class="fn"><a name="transform" /><a href="qtransform.html">QTransform</a> QGraphicsView.transform (<i>self</i>)</h3><p>Returns the current transformation matrix for the view. If no
845
current transformation is set, the identity matrix is returned.</p>
846
<p><b>See also</b> <a href="qgraphicsview.html#setTransform">setTransform</a>(), <a href="qgraphicsview.html#rotate">rotate</a>(), <a href="qgraphicsview.html#scale">scale</a>(), <a href="qgraphicsview.html#shear">shear</a>(), and <a href="qgraphicsview.html#translate">translate</a>().</p>
849
<h3 class="fn"><a name="transformationAnchor" /><a href="qgraphicsview.html#ViewportAnchor-enum">ViewportAnchor</a> QGraphicsView.transformationAnchor (<i>self</i>)</h3><h3 class="fn"><a name="translate" />QGraphicsView.translate (<i>self</i>, float <i>dx</i>, float <i>dy</i>)</h3><p>Translates the current view transformation by (<i>dx</i>,
851
<p><b>See also</b> <a href="qgraphicsview.html#setTransform">setTransform</a>(), <a href="qgraphicsview.html#transform">transform</a>(), <a href="qgraphicsview.html#rotate">rotate</a>(), and <a href="qgraphicsview.html#shear">shear</a>().</p>
854
<h3 class="fn"><a name="updateScene" />QGraphicsView.updateScene (<i>self</i>, list-of-QRectF <i>rects</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void updateScene(const QList<QRectF>&)</tt>.</p><p>Schedules an update of the scene rectangles <i>rects</i>.</p>
855
<p><b>See also</b> <a href="qgraphicsscene.html#changed">QGraphicsScene.changed</a>().</p>
858
<h3 class="fn"><a name="updateSceneRect" />QGraphicsView.updateSceneRect (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void updateSceneRect(const QRectF&)</tt>.</p><p>Notifies <a href="qgraphicsview.html">QGraphicsView</a> that the
859
scene's scene rect has changed. <i>rect</i> is the new scene rect.
860
If the view already has an explicitly set scene rect, this function
862
<p><b>See also</b> <a href="qgraphicsview.html#sceneRect-prop">sceneRect</a> and <a href="qgraphicsscene.html#sceneRectChanged">QGraphicsScene.sceneRectChanged</a>().</p>
865
<h3 class="fn"><a name="viewportEvent" />bool QGraphicsView.viewportEvent (<i>self</i>, <a href="qevent.html">QEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qabstractscrollarea.html#viewportEvent">QAbstractScrollArea.viewportEvent</a>().</p>
868
<h3 class="fn"><a name="viewportTransform" /><a href="qtransform.html">QTransform</a> QGraphicsView.viewportTransform (<i>self</i>)</h3><p>Returns a matrix that maps viewport coordinates to scene
870
<p><b>See also</b> <a href="qgraphicsview.html#mapToScene">mapToScene</a>() and <a href="qgraphicsview.html#mapFromScene">mapFromScene</a>().</p>
873
<h3 class="fn"><a name="viewportUpdateMode" /><a href="qgraphicsview.html#ViewportUpdateMode-enum">ViewportUpdateMode</a> QGraphicsView.viewportUpdateMode (<i>self</i>)</h3><h3 class="fn"><a name="wheelEvent" />QGraphicsView.wheelEvent (<i>self</i>, <a href="qwheelevent.html">QWheelEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#wheelEvent">QWidget.wheelEvent</a>().</p>
874
<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>
b'\\ No newline at end of file'