|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QWidget
com.trolltech.qt.gui.QFrame
com.trolltech.qt.gui.QAbstractScrollArea
com.trolltech.qt.gui.QGraphicsView
public class QGraphicsView
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene
. QGraphicsView visualizes the contents of a QGraphicsScene
in a scrollable viewport. To create a scene with geometrical items, see QGraphicsScene
's documentation. QGraphicsView is part of The Graphics View Framework.
To visualize a scene, you start by constructing a QGraphicsView object, passing the address of the scene you want to visualize to QGraphicsView's constructor. Alternatively, you can call setScene()
to set the scene at a later point. After you call show()
, the view will by default scroll to the center of the scene and display any items that are visible at this point. For example:
QGraphicsScene scene = new QGraphicsScene(); scene.addText("Hello, world!"); QGraphicsView view = new QGraphicsView(scene); view.show();You can explicitly scroll to any position on the scene by using the scroll bars, or by calling
centerOn()
. By passing a point to centerOn()
, QGraphicsView will scroll its viewport to ensure that the point is centered in the view. An overload is provided for scrolling to a QGraphicsItem
, in which case QGraphicsView will see to that the center of the item is centered in the view. If all you want is to ensure that a certain area is visible, (but not necessarily centered,) you can call ensureVisible()
instead. QGraphicsView can be used to visualize a whole scene, or only parts of it. The visualized area is by default detected automatically when the view is displayed for the first time (by calling QGraphicsScene::itemsBoundingRect()
). To set the visualized area rectangle yourself, you can call setSceneRect()
. This will adjust the scroll bars' ranges appropriately. Note that although the scene supports a virtually unlimited size, the range of the scroll bars will never exceed the range of an integer (INT_MIN, INT_MAX). When the scene is larger than the scroll bars' values, you can choose to use translate()
to navigate the scene instead.
QGraphicsView visualizes the scene by calling render()
. By default, the items are drawn onto the viewport by using a regular QPainter
, and using default render hints. To change the default render hints that QGraphicsView passes to QPainter
when painting items, you can call setRenderHints()
.
By default, QGraphicsView provides a regular QWidget
for the viewport widget. You can access this widget by calling viewport()
, or you can replace it by calling setViewport()
. To render using OpenGL, simply call setViewport(new QGLWidget
). QGraphicsView takes ownership of the viewport widget.
QGraphicsView supports affine transformations, using QMatrix
. You can either pass a matrix to setMatrix()
, or you can call one of the convenience functions rotate()
, scale()
, translate()
or shear()
. The most two common transformations are scaling, which is used to implement zooming, and rotation. QGraphicsView keeps the center of the view fixed during a transformation.
You can interact with the items on the scene by using the mouse and keyboard. QGraphicsView translates the mouse and key events into scene events, (events that inherit QGraphicsSceneEvent
,), and forward them to the visualized scene. In the end, it's the individual item that handles the events and reacts to them. For example, if you click on a selectable item, the item will typically let the scene know that it has been selected, and it will also redraw itself to display a selection rectangle. Similiary, if you click and drag the mouse to move a movable item, it's the item that handles the mouse moves and moves itself. Item interaction is enabled by default, and you can toggle it by calling setInteractive()
.
You can also provide your own custom scene interaction, by creating a subclass of QGraphicsView, and reimplementing the mouse and key event handlers. To simplify how you programmatically interact with items in the view, QGraphicsView provides the mapping functions mapToScene()
and mapFromScene()
, and the item accessors items()
and itemAt()
. These functions allow you to map points, rectangles, polygons and paths between view coordinates and scene coordinates, and to find items on the scene using view coordinates.
QGraphicsScene
, QGraphicsItem
, and QGraphicsSceneEvent
.
Nested Class Summary | |
---|---|
static class |
QGraphicsView.CacheMode
|
static class |
QGraphicsView.CacheModeFlag
This enum describes the flags that you can set for a QGraphicsView 's cache mode. |
static class |
QGraphicsView.DragMode
This enum describes the default action for the view when pressing and dragging the mouse over the viewport. |
static class |
QGraphicsView.OptimizationFlag
This enum describes flags that you can enable to improve rendering performance in QGraphicsView . |
static class |
QGraphicsView.OptimizationFlags
|
static class |
QGraphicsView.ViewportAnchor
This enums describe the possible anchors that QGraphicsView can use when the user resizes the view or when the view is transformed. |
static class |
QGraphicsView.ViewportUpdateMode
This enum describes how QGraphicsView updates its viewport when the scene contents change or are exposed. |
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QFrame |
---|
QFrame.Shadow, QFrame.Shape, QFrame.StyleMask |
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget |
---|
QWidget.RenderFlag, QWidget.RenderFlags |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary |
---|
Fields inherited from class com.trolltech.qt.gui.QWidget |
---|
customContextMenuRequested |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QGraphicsView()
Constructs a QGraphicsView. |
|
QGraphicsView(QGraphicsScene scene)
Constructs a QGraphicsView and sets the visualized scene to scene. |
|
QGraphicsView(QGraphicsScene scene,
QWidget parent)
Constructs a QGraphicsView and sets the visualized scene to scene. |
|
QGraphicsView(QWidget parent)
Constructs a QGraphicsView. |
Method Summary | |
---|---|
Qt.Alignment |
alignment()
This property holds the alignment of the scene in the view when the whole scene is visible. |
QBrush |
backgroundBrush()
This property holds the background brush of the scene. |
QGraphicsView.CacheMode |
cacheMode()
This property holds which parts of the view are cached. |
void |
centerOn(double x,
double y)
This is an overloaded member function, provided for convenience. |
void |
centerOn(QGraphicsItemInterface item)
This is an overloaded member function, provided for convenience. |
void |
centerOn(QPointF pos)
Scrolls the contents of the viewport to ensure that the scene coordinate pos, is centered in the view. |
QGraphicsView.DragMode |
dragMode()
This property holds the behavior for dragging the mouse over the scene while the left mouse button is pressed. |
protected void |
drawBackground(QPainter painter,
QRectF rect)
Draws the background of the scene using painter, before any items and the foreground are drawn. |
protected void |
drawForeground(QPainter painter,
QRectF rect)
Draws the foreground of the scene using painter, after the background and all items are drawn. |
protected void |
drawItems(QPainter painter,
QGraphicsItemInterface[] items,
QStyleOptionGraphicsItem[] options)
Draws the items items in the scene using painter, after the background and before the foreground are drawn. |
void |
ensureVisible(double x,
double y,
double w,
double h)
This is an overloaded member function, provided for convenience. |
void |
ensureVisible(double x,
double y,
double w,
double h,
int xmargin)
This is an overloaded member function, provided for convenience. |
void |
ensureVisible(double x,
double y,
double w,
double h,
int xmargin,
int ymargin)
This is an overloaded member function, provided for convenience. |
void |
ensureVisible(QGraphicsItemInterface item)
This is an overloaded member function, provided for convenience. |
void |
ensureVisible(QGraphicsItemInterface item,
int xmargin)
This is an overloaded member function, provided for convenience. |
void |
ensureVisible(QGraphicsItemInterface item,
int xmargin,
int ymargin)
This is an overloaded member function, provided for convenience. |
void |
ensureVisible(QRectF rect)
Scrolls the contents of the viewport so that the scene rectangle rect is visible, with margins specified in pixels by xmargin and ymargin. |
void |
ensureVisible(QRectF rect,
int xmargin)
Scrolls the contents of the viewport so that the scene rectangle rect is visible, with margins specified in pixels by xmargin and ymargin. |
void |
ensureVisible(QRectF rect,
int xmargin,
int ymargin)
Scrolls the contents of the viewport so that the scene rectangle rect is visible, with margins specified in pixels by xmargin and ymargin. |
void |
fitInView(double x,
double y,
double w,
double h)
This is an overloaded member function, provided for convenience. |
void |
fitInView(double x,
double y,
double w,
double h,
Qt.AspectRatioMode aspectRadioMode)
This is an overloaded member function, provided for convenience. |
void |
fitInView(QGraphicsItemInterface item)
This is an overloaded member function, provided for convenience. |
void |
fitInView(QGraphicsItemInterface item,
Qt.AspectRatioMode aspectRadioMode)
This is an overloaded member function, provided for convenience. |
void |
fitInView(QRectF rect)
Scales the view matrix and scrolls the scroll bars to ensure that the scene rectangle rect fits inside the viewport. |
void |
fitInView(QRectF rect,
Qt.AspectRatioMode aspectRadioMode)
Scales the view matrix and scrolls the scroll bars to ensure that the scene rectangle rect fits inside the viewport. |
QBrush |
foregroundBrush()
This property holds the foreground brush of the scene. |
void |
invalidateScene()
Invalidates and schedules a redraw of layers inside rect. |
void |
invalidateScene(QRectF rect)
Invalidates and schedules a redraw of layers inside rect. |
void |
invalidateScene(QRectF rect,
QGraphicsScene.SceneLayer[] layers)
|
void |
invalidateScene(QRectF rect,
QGraphicsScene.SceneLayers layers)
Invalidates and schedules a redraw of layers inside rect. |
boolean |
isInteractive()
This property holds whether the view allowed scene interaction. |
QGraphicsItemInterface |
itemAt(int x,
int y)
This is an overloaded member function, provided for convenience. |
QGraphicsItemInterface |
itemAt(QPoint pos)
Returns the item at position pos, which is in viewport coordinates. |
java.util.List |
items()
Returns a list of all the items in the associated scene. |
java.util.List |
items(int x,
int y)
This function is provided for convenience. |
java.util.List |
items(int x,
int y,
int w,
int h)
This convenience function is equivalent to calling items(QRectF(x, y, w, h)). |
java.util.List |
items(int x,
int y,
int w,
int h,
Qt.ItemSelectionMode mode)
This convenience function is equivalent to calling items( QRectF (x, y, w, h), mode). |
java.util.List |
items(QPainterPath path)
Returns a list of all the items that are either contained by or intersect with path. |
java.util.List |
items(QPainterPath path,
Qt.ItemSelectionMode mode)
This is an overloaded member function, provided for convenience. |
java.util.List |
items(QPoint pos)
Returns a list of all the items at the position pos in the view. |
java.util.List |
items(QPolygon polygon)
Returns a list of all the items that are either contained by or intersect with polygon. |
java.util.List |
items(QPolygon polygon,
Qt.ItemSelectionMode mode)
This is an overloaded member function, provided for convenience. |
java.util.List |
items(QRect rect)
Returns a list of all the items that are either contained by or intersect with rect. |
java.util.List |
items(QRect rect,
Qt.ItemSelectionMode mode)
This is an overloaded member function, provided for convenience. |
QPoint |
mapFromScene(double x,
double y)
This function is provided for convenience. |
QPolygon |
mapFromScene(double x,
double y,
double w,
double h)
This function is provided for convenience. |
QPainterPath |
mapFromScene(QPainterPath path)
Returns the scene coordinate painter path path to a viewport coordinate painter path. |
QPoint |
mapFromScene(QPointF point)
Returns the scene coordinate point to viewport coordinates. |
QPolygon |
mapFromScene(QPolygonF polygon)
Returns the scene coordinate polygon polygon to a viewport coordinate polygon. |
QPolygon |
mapFromScene(QRectF rect)
Returns the scene rectangle rect to a viewport coordinate polygon. |
QPointF |
mapToScene(int x,
int y)
This function is provided for convenience. |
QPolygonF |
mapToScene(int x,
int y,
int w,
int h)
This function is provided for convenience. |
QPainterPath |
mapToScene(QPainterPath path)
Returns the viewport painter path path mapped to a scene coordinate painter path. |
QPointF |
mapToScene(QPoint point)
Returns the viewport coordinate point mapped to scene coordinates. |
QPolygonF |
mapToScene(QPolygon polygon)
Returns the viewport polygon polygon mapped to a scene coordinate polygon. |
QPolygonF |
mapToScene(QRect rect)
Returns the viewport rectangle rect mapped to a scene coordinate polygon. |
QMatrix |
matrix()
Returns the current transformation matrix for the view. |
QGraphicsView.OptimizationFlags |
optimizationFlags()
This property holds flags that can be used to tune QGraphicsView's performance. |
void |
render(QPainter painter)
Renders the source rect, which is in view coordinates, from the scene into target, which is in paint device coordinates, using painter. |
void |
render(QPainter painter,
QRectF target)
Renders the source rect, which is in view coordinates, from the scene into target, which is in paint device coordinates, using painter. |
void |
render(QPainter painter,
QRectF target,
QRect source)
Renders the source rect, which is in view coordinates, from the scene into target, which is in paint device coordinates, using painter. |
void |
render(QPainter painter,
QRectF target,
QRect source,
Qt.AspectRatioMode aspectRatioMode)
Renders the source rect, which is in view coordinates, from the scene into target, which is in paint device coordinates, using painter. |
QPainter.RenderHints |
renderHints()
This property holds the default render hints for the view. |
void |
resetCachedContent()
Resets any cached content. |
void |
resetMatrix()
Resets the view transformation matrix to the identity matrix. |
void |
resetTransform()
Resets the view transformation to the identity matrix. |
QGraphicsView.ViewportAnchor |
resizeAnchor()
This property holds how the view should position the scene when the view is resized. |
void |
rotate(double angle)
Rotates the current view transformation angle degrees clockwise. |
Qt.ItemSelectionMode |
rubberBandSelectionMode()
This property holds the behavior for selecting items with a rubber band selection rectangle. |
void |
scale(double sx,
double sy)
Scales the current view transformation by (sx, sy). |
QGraphicsScene |
scene()
Returns a pointer to the scene that is currently visualized in the view. |
QRectF |
sceneRect()
This property holds the area of the scene visualized by this view. |
void |
setAlignment(Qt.Alignment alignment)
This property holds the alignment of the scene in the view when the whole scene is visible. |
void |
setAlignment(Qt.AlignmentFlag[] alignment)
|
void |
setBackgroundBrush(QBrush brush)
This property holds the background brush of the scene. |
void |
setCacheMode(QGraphicsView.CacheMode mode)
This property holds which parts of the view are cached. |
void |
setCacheMode(QGraphicsView.CacheModeFlag[] mode)
|
void |
setDragMode(QGraphicsView.DragMode mode)
This property holds the behavior for dragging the mouse over the scene while the left mouse button is pressed. |
void |
setForegroundBrush(QBrush brush)
This property holds the foreground brush of the scene. |
void |
setInteractive(boolean allowed)
This property holds whether the view allowed scene interaction. |
void |
setMatrix(QMatrix matrix)
Sets the view's current transformation matrix to matrix. |
void |
setMatrix(QMatrix matrix,
boolean combine)
Sets the view's current transformation matrix to matrix. |
void |
setOptimizationFlag(QGraphicsView.OptimizationFlag flag)
Enables flag if enabled is true; otherwise disables flag. |
void |
setOptimizationFlag(QGraphicsView.OptimizationFlag flag,
boolean enabled)
Enables flag if enabled is true; otherwise disables flag. |
void |
setOptimizationFlags(QGraphicsView.OptimizationFlag[] flags)
|
void |
setOptimizationFlags(QGraphicsView.OptimizationFlags flags)
This property holds flags that can be used to tune QGraphicsView's performance. |
void |
setRenderHint(QPainter.RenderHint hint)
If enabled is true, the render hint hint is enabled; otherwise it is disabled. |
void |
setRenderHint(QPainter.RenderHint hint,
boolean enabled)
If enabled is true, the render hint hint is enabled; otherwise it is disabled. |
void |
setRenderHints(QPainter.RenderHint[] hints)
|
void |
setRenderHints(QPainter.RenderHints hints)
This property holds the default render hints for the view. |
void |
setResizeAnchor(QGraphicsView.ViewportAnchor anchor)
This property holds how the view should position the scene when the view is resized. |
void |
setRubberBandSelectionMode(Qt.ItemSelectionMode mode)
This property holds the behavior for selecting items with a rubber band selection rectangle. |
void |
setScene(QGraphicsScene scene)
Sets the current scene to scene. |
void |
setSceneRect(double x,
double y,
double w,
double h)
This property holds the area of the scene visualized by this view. |
void |
setSceneRect(QRectF rect)
This property holds the area of the scene visualized by this view. |
void |
setTransform(QTransform matrix)
Sets the view's current transformation matrix to matrix. |
void |
setTransform(QTransform matrix,
boolean combine)
Sets the view's current transformation matrix to matrix. |
void |
setTransformationAnchor(QGraphicsView.ViewportAnchor anchor)
This property holds how the view should position the scene during transformations. |
void |
setViewportUpdateMode(QGraphicsView.ViewportUpdateMode mode)
This property holds how the viewport should update its contents. |
void |
shear(double sh,
double sv)
Shears the current view transformation by (sh, sv). |
QTransform |
transform()
Returns the current transformation matrix for the view. |
QGraphicsView.ViewportAnchor |
transformationAnchor()
This property holds how the view should position the scene during transformations. |
void |
translate(double dx,
double dy)
Translates the current view transformation by (dx, dy). |
void |
updateScene(java.util.List rects)
Schedules an update of the scene rectangles rects. |
void |
updateSceneRect(QRectF rect)
Notifies QGraphicsView that the scene's scene rect has changed. |
QTransform |
viewportTransform()
Returns a matrix that maps viewport coordinates to scene coordinates. |
QGraphicsView.ViewportUpdateMode |
viewportUpdateMode()
This property holds how the viewport should update its contents. |
Methods inherited from class com.trolltech.qt.gui.QFrame |
---|
frameRect, frameShadow, frameShape, frameStyle, frameWidth, lineWidth, midLineWidth, setFrameRect, setFrameShadow, setFrameShape, setFrameStyle, setLineWidth, setMidLineWidth |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QGraphicsView(QGraphicsScene scene)
QWidget
's constructor.
public QGraphicsView(QGraphicsScene scene, QWidget parent)
QWidget
's constructor.
public QGraphicsView()
QWidget
's constructor.
public QGraphicsView(QWidget parent)
QWidget
's constructor.
Method Detail |
---|
public final Qt.Alignment alignment()
Qt::AlignCenter
, which is default, the scene will be centered in the view, and if the alignment is (Qt::AlignLeft
| Qt::AlignTop
), the scene will be rendered in the top-left corner of the view.
public final QBrush backgroundBrush()
drawBackground()
. To provide custom background drawing for this view, you can reimplement drawBackground()
instead. By default, this property contains a brush with the Qt::NoBrush
pattern.
QGraphicsScene::backgroundBrush
, and foregroundBrush
.
public final QGraphicsView.CacheMode cacheMode()
QPixmap
, which is then drawn onto the viewport. The purpose of such caching is to speed up the total rendering time for areas that are slow to render. Texture, gradient and alpha blended backgrounds, for example, can be notibly slow to render; especially with a transformed view. The CacheBackground
flag enables caching of the view's background. For example: QGraphicsView view = new QGraphicsView(); view.setBackgroundBrush(new QBrush(new QImage(":/images/backgroundtile.png"))); view.setCacheMode(QGraphicsView.CacheModeFlag.CacheBackground);The cache is invalidated every time the view is transformed. However, when scrolling, only partial invalidation is required.
By default, nothing is cached.
resetCachedContent()
, and QPixmapCache
.
public final void centerOn(QGraphicsItemInterface item)
Scrolls the contents of the viewport to ensure that item is centered in the view.
ensureVisible()
.
public final void centerOn(QPointF pos)
Because pos is a floating point coordinate, and the scroll bars operate on integer coordinates, the centering is only an approximation.
Note: If the item is close to or outside the border, it will be visible in the view, but not centered.
ensureVisible()
.
public final void centerOn(double x, double y)
This function is provided for convenience. It's equivalent to calling centerOn(QPointF
(x, y)).
public final QGraphicsView.DragMode dragMode()
NoDrag
, does nothing. This behavior only affects mouse clicks that are not handled by any item. You can define a custom behavior by creating a subclass of QGraphicsView and reimplementing mouseMoveEvent()
.
public final void ensureVisible(QGraphicsItemInterface item, int xmargin)
Scrolls the contents of the viewport so that the center of item item is visible, with margins specified in pixels by xmargin and ymargin. If the specified point cannot be reached, the contents are scrolled to the nearest valid position. The default value for both margins is 50 pixels.
centerOn()
.
public final void ensureVisible(QGraphicsItemInterface item)
Scrolls the contents of the viewport so that the center of item item is visible, with margins specified in pixels by xmargin and ymargin. If the specified point cannot be reached, the contents are scrolled to the nearest valid position. The default value for both margins is 50 pixels.
centerOn()
.
public final void ensureVisible(QGraphicsItemInterface item, int xmargin, int ymargin)
Scrolls the contents of the viewport so that the center of item item is visible, with margins specified in pixels by xmargin and ymargin. If the specified point cannot be reached, the contents are scrolled to the nearest valid position. The default value for both margins is 50 pixels.
centerOn()
.
public final void ensureVisible(QRectF rect, int xmargin)
centerOn()
.
public final void ensureVisible(QRectF rect)
centerOn()
.
public final void ensureVisible(QRectF rect, int xmargin, int ymargin)
centerOn()
.
public final void ensureVisible(double x, double y, double w, double h, int xmargin)
This function is provided for convenience. It's equivalent to calling ensureVisible(QRectF
(x, y, w, h), xmargin, ymargin).
public final void ensureVisible(double x, double y, double w, double h)
This function is provided for convenience. It's equivalent to calling ensureVisible(QRectF
(x, y, w, h), xmargin, ymargin).
public final void ensureVisible(double x, double y, double w, double h, int xmargin, int ymargin)
This function is provided for convenience. It's equivalent to calling ensureVisible(QRectF
(x, y, w, h), xmargin, ymargin).
public final void fitInView(QGraphicsItemInterface item)
Ensures that item fits tightly inside the view, scaling the view according to aspectRatioMode.
ensureVisible()
, and centerOn()
.
public final void fitInView(QGraphicsItemInterface item, Qt.AspectRatioMode aspectRadioMode)
Ensures that item fits tightly inside the view, scaling the view according to aspectRatioMode.
ensureVisible()
, and centerOn()
.
public final void fitInView(QRectF rect)
fitInView()
cannot guarantee that the whole rect is visible. This function keeps the view's rotation, translation, or shear. The view is scaled according to aspectRatioMode. rect will be centered in the view if it does not fit tightly.
It's common to call fitInView()
from inside a reimplementation of resizeEvent()
, to ensure that the whole scene, or parts of the scene, scales automatically to fit the new size of the viewport as the view is resized. Note though, that calling fitInView()
from inside resizeEvent()
can lead to unwanted resize recursion, if the new transformation toggles the automatic state of the scrollbars. You can toggle the scrollbar policies to always on or always off to prevent this (see horizontalScrollBarPolicy() and verticalScrollBarPolicy()).
If rect is empty, or if the viewport is too small, this function will do nothing.
setMatrix()
, ensureVisible()
, and centerOn()
.
public final void fitInView(QRectF rect, Qt.AspectRatioMode aspectRadioMode)
fitInView()
cannot guarantee that the whole rect is visible. This function keeps the view's rotation, translation, or shear. The view is scaled according to aspectRatioMode. rect will be centered in the view if it does not fit tightly.
It's common to call fitInView()
from inside a reimplementation of resizeEvent()
, to ensure that the whole scene, or parts of the scene, scales automatically to fit the new size of the viewport as the view is resized. Note though, that calling fitInView()
from inside resizeEvent()
can lead to unwanted resize recursion, if the new transformation toggles the automatic state of the scrollbars. You can toggle the scrollbar policies to always on or always off to prevent this (see horizontalScrollBarPolicy() and verticalScrollBarPolicy()).
If rect is empty, or if the viewport is too small, this function will do nothing.
setMatrix()
, ensureVisible()
, and centerOn()
.
public final void fitInView(double x, double y, double w, double h)
This convenience function is equivalent to calling fitInView(QRectF
(x, y, w, h), aspectRatioMode).
ensureVisible()
, and centerOn()
.
public final void fitInView(double x, double y, double w, double h, Qt.AspectRatioMode aspectRadioMode)
This convenience function is equivalent to calling fitInView(QRectF
(x, y, w, h), aspectRatioMode).
ensureVisible()
, and centerOn()
.
public final QBrush foregroundBrush()
drawForeground()
. To provide custom foreground drawing for this view, you can reimplement drawForeground()
instead. By default, this property contains a brush with the Qt::NoBrush
pattern.
QGraphicsScene::foregroundBrush
, and backgroundBrush
.
public final void invalidateScene(QRectF rect, QGraphicsScene.SceneLayer[] layers)
public final void invalidateScene(QRectF rect)
You can call this function to notify QGraphicsView of changes to the background or the foreground of the scene. It is commonly used for scenes with tile-based backgrounds to notify changes when QGraphicsView has enabled background caching.
Note that QGraphicsView currently supports background caching only (see QGraphicsView::CacheBackground
). This function is equivalent to calling update()
if any layer but QGraphicsScene::BackgroundLayer
is passed.
QGraphicsScene::invalidate()
, and update()
.
public final void invalidateScene()
You can call this function to notify QGraphicsView of changes to the background or the foreground of the scene. It is commonly used for scenes with tile-based backgrounds to notify changes when QGraphicsView has enabled background caching.
Note that QGraphicsView currently supports background caching only (see QGraphicsView::CacheBackground
). This function is equivalent to calling update()
if any layer but QGraphicsScene::BackgroundLayer
is passed.
QGraphicsScene::invalidate()
, and update()
.
public final void invalidateScene(QRectF rect, QGraphicsScene.SceneLayers layers)
You can call this function to notify QGraphicsView of changes to the background or the foreground of the scene. It is commonly used for scenes with tile-based backgrounds to notify changes when QGraphicsView has enabled background caching.
Note that QGraphicsView currently supports background caching only (see QGraphicsView::CacheBackground
). This function is equivalent to calling update()
if any layer but QGraphicsScene::BackgroundLayer
is passed.
QGraphicsScene::invalidate()
, and update()
.
public final boolean isInteractive()
By default, this property is true.
public final QGraphicsItemInterface itemAt(QPoint pos)
Example:
protected void mousePressEvent(QMouseEvent event) { QGraphicsItemInterface item = itemAt(event.pos()); if (item != null) { System.out.println("You clicked on item " + item); } else { System.out.println("You didn't click on an item."); } }
items()
.
public final QGraphicsItemInterface itemAt(int x, int y)
This function is provided for convenience. It's equivalent to calling itemAt(QPoint
(x, y)).
public final java.util.List items()
QGraphicsScene::items()
.
public final java.util.List items(QPainterPath path)
public final java.util.List items(QPainterPath path, Qt.ItemSelectionMode mode)
Returns a list of all the items that, depending on mode, are either contained by or intersect with path. path is in viewport coordinates.
The default value for mode is Qt::IntersectsItemShape
; all items whose exact shape intersects with or is contained by path are returned.
itemAt()
, items()
, and mapToScene()
.
public final java.util.List items(QPoint pos)
This function is most commonly called from within mouse event handlers in a subclass in QGraphicsView. pos is in untransformed viewport coordinates, just like QMouseEvent::pos()
.
protected void mousePressEvent(QMouseEvent event) { System.out.println("There are " + items(event.pos()).size() + " items at position " + mapToScene(event.pos())); }
QGraphicsScene::items()
, and QGraphicsItem::zValue()
.
public final java.util.List items(QPolygon polygon)
public final java.util.List items(QPolygon polygon, Qt.ItemSelectionMode mode)
Returns a list of all the items that, depending on mode, are either contained by or intersect with polygon. polygon is in viewport coordinates.
The default value for mode is Qt::IntersectsItemShape
; all items whose exact shape intersects with or is contained by polygon are returned.
itemAt()
, items()
, and mapToScene()
.
public final java.util.List items(QRect rect)
public final java.util.List items(QRect rect, Qt.ItemSelectionMode mode)
Returns a list of all the items that, depending on mode, are either contained by or intersect with rect. rect is in viewport coordinates.
The default value for mode is Qt::IntersectsItemShape
; all items whose exact shape intersects with or is contained by rect are returned.
itemAt()
, items()
, and mapToScene()
.
public final java.util.List items(int x, int y)
QPoint
(x, y)).
public final java.util.List items(int x, int y, int w, int h)
public final java.util.List items(int x, int y, int w, int h, Qt.ItemSelectionMode mode)
QRectF
(x, y, w, h), mode).
public final QPainterPath mapFromScene(QPainterPath path)
mapToScene()
.
public final QPoint mapFromScene(QPointF point)
mapToScene()
.
public final QPolygon mapFromScene(QPolygonF polygon)
mapToScene()
.
public final QPolygon mapFromScene(QRectF rect)
mapToScene()
.
public final QPoint mapFromScene(double x, double y)
QPointF
(x, y)).
public final QPolygon mapFromScene(double x, double y, double w, double h)
QRectF
(x, y, w, h)).
public final QPainterPath mapToScene(QPainterPath path)
mapFromScene()
.
public final QPointF mapToScene(QPoint point)
Note: It can be useful to map the whole rectangle covered by the pixel at point instead of the point itself. To do this, you can call mapToScene(QRect
(point, QSize
(2, 2))).
mapFromScene()
.
public final QPolygonF mapToScene(QPolygon polygon)
mapFromScene()
.
public final QPolygonF mapToScene(QRect rect)
mapFromScene()
.
public final QPointF mapToScene(int x, int y)
QPoint
(x, y)).
public final QPolygonF mapToScene(int x, int y, int w, int h)
QRect
(x, y, w, h)).
public final QMatrix matrix()
setMatrix()
, rotate()
, scale()
, shear()
, and translate()
.
public final QGraphicsView.OptimizationFlags optimizationFlags()
The effect varies from flag to flag; see the OptimizationFlags documentation for details.
By default, no optimization flags are enabled.
setOptimizationFlag()
.
public final void render(QPainter painter, QRectF target, QRect source)
QImage
(e.g., to take a screenshot), or for printing to QPrinter
. For example: QGraphicsScene scene = new QGraphicsScene(); // scene.addItem(... QGraphicsView view = new QGraphicsView(scene); view.show(); // ... QPrinter printer = new QPrinter(QPrinter.PrinterMode.HighResolution); printer.setPageSize(QPrinter.PageSize.A4); QPainter painter = new QPainter(printer); // print, fitting the viewport contents into a full page view.render(painter); // print the upper half of the viewport into the lower. // half of the page. QRect viewport = view.viewport().rect(); view.render(painter, new QRectF(0, printer.height() / 2, printer.width(), printer.height() / 2), viewport.adjusted(0, 0, 0, -viewport.height() / 2) );If source is a null rect, this function will use
viewport()
->rect() to determine what to draw. If target is a null rect, the full dimensions of painter's paint device (e.g., for a QPrinter
, the page size) will be used. The source rect contents will be transformed according to aspectRatioMode to fit into the target rect. By default, the aspect ratio is kept, and source is scaled to fit in target.
QGraphicsScene::render()
.
public final void render(QPainter painter, QRectF target)
QImage
(e.g., to take a screenshot), or for printing to QPrinter
. For example: QGraphicsScene scene = new QGraphicsScene(); // scene.addItem(... QGraphicsView view = new QGraphicsView(scene); view.show(); // ... QPrinter printer = new QPrinter(QPrinter.PrinterMode.HighResolution); printer.setPageSize(QPrinter.PageSize.A4); QPainter painter = new QPainter(printer); // print, fitting the viewport contents into a full page view.render(painter); // print the upper half of the viewport into the lower. // half of the page. QRect viewport = view.viewport().rect(); view.render(painter, new QRectF(0, printer.height() / 2, printer.width(), printer.height() / 2), viewport.adjusted(0, 0, 0, -viewport.height() / 2) );If source is a null rect, this function will use
viewport()
->rect() to determine what to draw. If target is a null rect, the full dimensions of painter's paint device (e.g., for a QPrinter
, the page size) will be used. The source rect contents will be transformed according to aspectRatioMode to fit into the target rect. By default, the aspect ratio is kept, and source is scaled to fit in target.
QGraphicsScene::render()
.
public final void render(QPainter painter)
QImage
(e.g., to take a screenshot), or for printing to QPrinter
. For example: QGraphicsScene scene = new QGraphicsScene(); // scene.addItem(... QGraphicsView view = new QGraphicsView(scene); view.show(); // ... QPrinter printer = new QPrinter(QPrinter.PrinterMode.HighResolution); printer.setPageSize(QPrinter.PageSize.A4); QPainter painter = new QPainter(printer); // print, fitting the viewport contents into a full page view.render(painter); // print the upper half of the viewport into the lower. // half of the page. QRect viewport = view.viewport().rect(); view.render(painter, new QRectF(0, printer.height() / 2, printer.width(), printer.height() / 2), viewport.adjusted(0, 0, 0, -viewport.height() / 2) );If source is a null rect, this function will use
viewport()
->rect() to determine what to draw. If target is a null rect, the full dimensions of painter's paint device (e.g., for a QPrinter
, the page size) will be used. The source rect contents will be transformed according to aspectRatioMode to fit into the target rect. By default, the aspect ratio is kept, and source is scaled to fit in target.
QGraphicsScene::render()
.
public final void render(QPainter painter, QRectF target, QRect source, Qt.AspectRatioMode aspectRatioMode)
QImage
(e.g., to take a screenshot), or for printing to QPrinter
. For example: QGraphicsScene scene = new QGraphicsScene(); // scene.addItem(... QGraphicsView view = new QGraphicsView(scene); view.show(); // ... QPrinter printer = new QPrinter(QPrinter.PrinterMode.HighResolution); printer.setPageSize(QPrinter.PageSize.A4); QPainter painter = new QPainter(printer); // print, fitting the viewport contents into a full page view.render(painter); // print the upper half of the viewport into the lower. // half of the page. QRect viewport = view.viewport().rect(); view.render(painter, new QRectF(0, printer.height() / 2, printer.width(), printer.height() / 2), viewport.adjusted(0, 0, 0, -viewport.height() / 2) );If source is a null rect, this function will use
viewport()
->rect() to determine what to draw. If target is a null rect, the full dimensions of painter's paint device (e.g., for a QPrinter
, the page size) will be used. The source rect contents will be transformed according to aspectRatioMode to fit into the target rect. By default, the aspect ratio is kept, and source is scaled to fit in target.
QGraphicsScene::render()
.
public final QPainter.RenderHints renderHints()
QPainter
before each visible item is drawn. QPainter
uses render hints to toggle rendering features such as antialiasing and smooth pixmap transformation. QPainter::TextAntialiasing
is enabled by default.
Example:
QGraphicsScene scene = new QGraphicsScene(); scene.addRect(new QRectF(-10, -10, 20, 20)); QGraphicsView view = new QGraphicsView(scene); view.setRenderHints(QPainter.RenderHint.Antialiasing, QPainter.RenderHint.SmoothPixmapTransform); view.show();
public final void resetCachedContent()
CacheNone
, this function does nothing. This function is called automatically for you when the backgroundBrush
or QGraphicsScene::backgroundBrush
properties change; you only need to call this function if you have reimplemented QGraphicsScene::drawBackground()
or QGraphicsView::drawBackground()
to draw a custom background, and need to trigger a full redraw.
cacheMode()
.
public final void resetMatrix()
public final void resetTransform()
transform()
, and setTransform()
.
public final QGraphicsView.ViewportAnchor resizeAnchor()
NoAnchor
, leaves the scene's position unchanged during a resize; the top-left corner of the view will appear to be anchored while resizing. Note that the effect of this property is noticeable when only a part of the scene is visible (i.e., when there are scroll bars). Otherwise, if the whole scene fits in the view, QGraphicsScene
uses the view alignment
to position the scene in the view.
alignment
, transformationAnchor
, and Qt::WNorthWestGravity
.
public final void rotate(double angle)
setMatrix()
, matrix()
, scale()
, shear()
, and translate()
.
public final Qt.ItemSelectionMode rubberBandSelectionMode()
RubberBandDrag
drag mode. The default value is Qt::IntersectsItemShape
; all items whose shape intersects with or is contained by the rubber band are selected.
dragMode
, and items()
.
public final void scale(double sx, double sy)
setMatrix()
, matrix()
, rotate()
, shear()
, and translate()
.
public final QGraphicsScene scene()
setScene()
.
public final QRectF sceneRect()
If unset, or if a null QRectF
is set, this property has the same value as QGraphicsScene::sceneRect
, and it changes with QGraphicsScene::sceneRect
. Otherwise, the view's scene rect is unaffected by the scene.
Note that, although the scene supports a virtually unlimited size, the range of the scroll bars will never exceed the range of an integer (INT_MIN, INT_MAX). When the scene is larger than the scroll bars' values, you can choose to use translate()
to navigate the scene instead.
By default, this property contains a rectangle at the origin with zero width and height.
QGraphicsScene::sceneRect
.
public final void setAlignment(Qt.AlignmentFlag[] alignment)
public final void setAlignment(Qt.Alignment alignment)
Qt::AlignCenter
, which is default, the scene will be centered in the view, and if the alignment is (Qt::AlignLeft
| Qt::AlignTop
), the scene will be rendered in the top-left corner of the view.
public final void setBackgroundBrush(QBrush brush)
drawBackground()
. To provide custom background drawing for this view, you can reimplement drawBackground()
instead. By default, this property contains a brush with the Qt::NoBrush
pattern.
QGraphicsScene::backgroundBrush
, and foregroundBrush
.
public final void setCacheMode(QGraphicsView.CacheModeFlag[] mode)
public final void setCacheMode(QGraphicsView.CacheMode mode)
QPixmap
, which is then drawn onto the viewport. The purpose of such caching is to speed up the total rendering time for areas that are slow to render. Texture, gradient and alpha blended backgrounds, for example, can be notibly slow to render; especially with a transformed view. The CacheBackground
flag enables caching of the view's background. For example: QGraphicsView view = new QGraphicsView(); view.setBackgroundBrush(new QBrush(new QImage(":/images/backgroundtile.png"))); view.setCacheMode(QGraphicsView.CacheModeFlag.CacheBackground);The cache is invalidated every time the view is transformed. However, when scrolling, only partial invalidation is required.
By default, nothing is cached.
resetCachedContent()
, and QPixmapCache
.
public final void setDragMode(QGraphicsView.DragMode mode)
NoDrag
, does nothing. This behavior only affects mouse clicks that are not handled by any item. You can define a custom behavior by creating a subclass of QGraphicsView and reimplementing mouseMoveEvent()
.
public final void setForegroundBrush(QBrush brush)
drawForeground()
. To provide custom foreground drawing for this view, you can reimplement drawForeground()
instead. By default, this property contains a brush with the Qt::NoBrush
pattern.
QGraphicsScene::foregroundBrush
, and backgroundBrush
.
public final void setInteractive(boolean allowed)
By default, this property is true.
public final void setMatrix(QMatrix matrix)
If combine is true, then matrix is combined with the current matrix; otherwise, matrixreplaces the current matrix. combine is false by default.
The transformation matrix tranforms the scene into view coordinates. Using the default transformation, provided by the identity matrix, one pixel in the view represents one unit in the scene (e.g., a 10x10 rectangular item is drawn using 10x10 pixels in the view). If a 2x2 scaling matrix is applied, the scene will be drawn in 1:2 (e.g., a 10x10 rectangular item is then drawn using 20x20 pixels in the view).
Example:
QGraphicsScene scene = new QGraphicsScene(); scene.addText("GraphicsView rotated clockwise"); QGraphicsView view = new QGraphicsView(scene); view.rotate(90); // the text is rendered with a 90 degree clockwise rotation view.show();To simplify interation with items using a transformed view, QGraphicsView provides mapTo... and mapFrom... functions that can translate between scene and view coordinates. For example, you can call
mapToScene()
to map a view coordinate to a floating point scene coordinate, or mapFromScene()
to map from floating point scene coordinates to view coordinates. matrix()
, rotate()
, scale()
, shear()
, and translate()
.
public final void setMatrix(QMatrix matrix, boolean combine)
If combine is true, then matrix is combined with the current matrix; otherwise, matrixreplaces the current matrix. combine is false by default.
The transformation matrix tranforms the scene into view coordinates. Using the default transformation, provided by the identity matrix, one pixel in the view represents one unit in the scene (e.g., a 10x10 rectangular item is drawn using 10x10 pixels in the view). If a 2x2 scaling matrix is applied, the scene will be drawn in 1:2 (e.g., a 10x10 rectangular item is then drawn using 20x20 pixels in the view).
Example:
QGraphicsScene scene = new QGraphicsScene(); scene.addText("GraphicsView rotated clockwise"); QGraphicsView view = new QGraphicsView(scene); view.rotate(90); // the text is rendered with a 90 degree clockwise rotation view.show();To simplify interation with items using a transformed view, QGraphicsView provides mapTo... and mapFrom... functions that can translate between scene and view coordinates. For example, you can call
mapToScene()
to map a view coordinate to a floating point scene coordinate, or mapFromScene()
to map from floating point scene coordinates to view coordinates. matrix()
, rotate()
, scale()
, shear()
, and translate()
.
public final void setOptimizationFlag(QGraphicsView.OptimizationFlag flag)
optimizationFlags
.
public final void setOptimizationFlag(QGraphicsView.OptimizationFlag flag, boolean enabled)
optimizationFlags
.
public final void setOptimizationFlags(QGraphicsView.OptimizationFlag[] flags)
public final void setOptimizationFlags(QGraphicsView.OptimizationFlags flags)
The effect varies from flag to flag; see the OptimizationFlags documentation for details.
By default, no optimization flags are enabled.
setOptimizationFlag()
.
public final void setRenderHint(QPainter.RenderHint hint)
renderHints
.
public final void setRenderHint(QPainter.RenderHint hint, boolean enabled)
renderHints
.
public final void setRenderHints(QPainter.RenderHint[] hints)
public final void setRenderHints(QPainter.RenderHints hints)
QPainter
before each visible item is drawn. QPainter
uses render hints to toggle rendering features such as antialiasing and smooth pixmap transformation. QPainter::TextAntialiasing
is enabled by default.
Example:
QGraphicsScene scene = new QGraphicsScene(); scene.addRect(new QRectF(-10, -10, 20, 20)); QGraphicsView view = new QGraphicsView(scene); view.setRenderHints(QPainter.RenderHint.Antialiasing, QPainter.RenderHint.SmoothPixmapTransform); view.show();
public final void setResizeAnchor(QGraphicsView.ViewportAnchor anchor)
NoAnchor
, leaves the scene's position unchanged during a resize; the top-left corner of the view will appear to be anchored while resizing. Note that the effect of this property is noticeable when only a part of the scene is visible (i.e., when there are scroll bars). Otherwise, if the whole scene fits in the view, QGraphicsScene
uses the view alignment
to position the scene in the view.
alignment
, transformationAnchor
, and Qt::WNorthWestGravity
.
public final void setRubberBandSelectionMode(Qt.ItemSelectionMode mode)
RubberBandDrag
drag mode. The default value is Qt::IntersectsItemShape
; all items whose shape intersects with or is contained by the rubber band are selected.
dragMode
, and items()
.
public final void setScene(QGraphicsScene scene)
When a scene is set on a view, the QGraphicsScene::changed()
signal is automatically connected to this view's updateScene()
slot, and the view's scroll bars are adjusted to fit the size of the scene.
scene()
.
public final void setSceneRect(QRectF rect)
If unset, or if a null QRectF
is set, this property has the same value as QGraphicsScene::sceneRect
, and it changes with QGraphicsScene::sceneRect
. Otherwise, the view's scene rect is unaffected by the scene.
Note that, although the scene supports a virtually unlimited size, the range of the scroll bars will never exceed the range of an integer (INT_MIN, INT_MAX). When the scene is larger than the scroll bars' values, you can choose to use translate()
to navigate the scene instead.
By default, this property contains a rectangle at the origin with zero width and height.
QGraphicsScene::sceneRect
.
public final void setSceneRect(double x, double y, double w, double h)
If unset, or if a null QRectF
is set, this property has the same value as QGraphicsScene::sceneRect
, and it changes with QGraphicsScene::sceneRect
. Otherwise, the view's scene rect is unaffected by the scene.
Note that, although the scene supports a virtually unlimited size, the range of the scroll bars will never exceed the range of an integer (INT_MIN, INT_MAX). When the scene is larger than the scroll bars' values, you can choose to use translate()
to navigate the scene instead.
By default, this property contains a rectangle at the origin with zero width and height.
QGraphicsScene::sceneRect
.
public final void setTransform(QTransform matrix)
If combine is true, then matrix is combined with the current matrix; otherwise, matrixreplaces the current matrix. combine is false by default.
The transformation matrix tranforms the scene into view coordinates. Using the default transformation, provided by the identity matrix, one pixel in the view represents one unit in the scene (e.g., a 10x10 rectangular item is drawn using 10x10 pixels in the view). If a 2x2 scaling matrix is applied, the scene will be drawn in 1:2 (e.g., a 10x10 rectangular item is then drawn using 20x20 pixels in the view).
Example:
QGraphicsScene scene = new QGraphicsScene(); scene.addText("GraphicsView rotated clockwise"); QGraphicsView view = new QGraphicsView(scene); view.rotate(90); // the text is rendered with a 90 degree clockwise rotation view.show();To simplify interation with items using a transformed view, QGraphicsView provides mapTo... and mapFrom... functions that can translate between scene and view coordinates. For example, you can call
mapToScene()
to map a view coordiate to a floating point scene coordinate, or mapFromScene()
to map from floating point scene coordinates to view coordinates. transform()
, rotate()
, scale()
, shear()
, and translate()
.
public final void setTransform(QTransform matrix, boolean combine)
If combine is true, then matrix is combined with the current matrix; otherwise, matrixreplaces the current matrix. combine is false by default.
The transformation matrix tranforms the scene into view coordinates. Using the default transformation, provided by the identity matrix, one pixel in the view represents one unit in the scene (e.g., a 10x10 rectangular item is drawn using 10x10 pixels in the view). If a 2x2 scaling matrix is applied, the scene will be drawn in 1:2 (e.g., a 10x10 rectangular item is then drawn using 20x20 pixels in the view).
Example:
QGraphicsScene scene = new QGraphicsScene(); scene.addText("GraphicsView rotated clockwise"); QGraphicsView view = new QGraphicsView(scene); view.rotate(90); // the text is rendered with a 90 degree clockwise rotation view.show();To simplify interation with items using a transformed view, QGraphicsView provides mapTo... and mapFrom... functions that can translate between scene and view coordinates. For example, you can call
mapToScene()
to map a view coordiate to a floating point scene coordinate, or mapFromScene()
to map from floating point scene coordinates to view coordinates. transform()
, rotate()
, scale()
, shear()
, and translate()
.
public final void setTransformationAnchor(QGraphicsView.ViewportAnchor anchor)
AnchorViewCenter
, ensures that the scene point at the center of the view remains unchanged during transformations (e.g., when rotating, the scene will appear to rotate around the center of the view). Note that the effect of this property is noticeable when only a part of the scene is visible (i.e., when there are scroll bars). Otherwise, if the whole scene fits in the view, QGraphicsScene
uses the view alignment
to position the scene in the view.
alignment
, and resizeAnchor
.
public final void setViewportUpdateMode(QGraphicsView.ViewportUpdateMode mode)
ViewportUpdateMode
documentation for specific details. The default value is MinimalViewportUpdate
, where QGraphicsView will update as small an area of the viewport as possible when the contents change.
ViewportUpdateMode
, and cacheMode
.
public final void shear(double sh, double sv)
setMatrix()
, matrix()
, rotate()
, scale()
, and translate()
.
public final QTransform transform()
setTransform()
, rotate()
, scale()
, shear()
, and translate()
.
public final QGraphicsView.ViewportAnchor transformationAnchor()
AnchorViewCenter
, ensures that the scene point at the center of the view remains unchanged during transformations (e.g., when rotating, the scene will appear to rotate around the center of the view). Note that the effect of this property is noticeable when only a part of the scene is visible (i.e., when there are scroll bars). Otherwise, if the whole scene fits in the view, QGraphicsScene
uses the view alignment
to position the scene in the view.
alignment
, and resizeAnchor
.
public final void translate(double dx, double dy)
setMatrix()
, matrix()
, rotate()
, and shear()
.
public final void updateScene(java.util.List rects)
QGraphicsScene::changed()
.
public final void updateSceneRect(QRectF rect)
sceneRect
, and QGraphicsScene::sceneRectChanged()
.
public final QTransform viewportTransform()
mapToScene()
, and mapFromScene()
.
public final QGraphicsView.ViewportUpdateMode viewportUpdateMode()
ViewportUpdateMode
documentation for specific details. The default value is MinimalViewportUpdate
, where QGraphicsView will update as small an area of the viewport as possible when the contents change.
ViewportUpdateMode
, and cacheMode
.
protected void drawBackground(QPainter painter, QRectF rect)
If all you want is to define a color, texture or gradient for the background, you can call setBackgroundBrush()
instead.
All painting is done in scene coordinates. rect is the exposed rectangle.
The default implementation fills rect using the view's backgroundBrush
. If no such brush is defined (the default), the scene's drawBackground()
function is called instead.
drawForeground()
, and QGraphicsScene::drawBackground()
.
protected void drawForeground(QPainter painter, QRectF rect)
If all you want is to define a color, texture or gradient for the foreground, you can call setForegroundBrush()
instead.
All painting is done in scene coordinates. rect is the exposed rectangle.
The default implementation fills rect using the view's foregroundBrush
. If no such brush is defined (the default), the scene's drawForeground()
function is called instead.
drawBackground()
, and QGraphicsScene::drawForeground()
.
protected void drawItems(QPainter painter, QGraphicsItemInterface[] items, QStyleOptionGraphicsItem[] options)
The default implementation calls the scene's drawItems()
function.
drawForeground()
, drawBackground()
, and QGraphicsScene::drawItems()
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |