PythonQt.QtGui.QGraphicsItem · declarations 003
Back to PythonQt.QtGui.QGraphicsItem
mapToParent
mapToParent(x: Any, y: Any, w: Any, h: Any) -> Any
X.mapToParent(x, y, w, h) -> PythonQt.QtGui.QPainterPath
Supplemental documentation: Qt 5 reference:
QPointF QGraphicsItem::mapToParent(const QPointF \&point) const
Maps the point point, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped coordinate. If the item has no parent, point will be mapped to the scene's coordinate system.
See also mapToItem(), mapToScene(), transform(), mapFromParent(), and The Graphics View Coordinate System.
QPolygonF QGraphicsItem::mapToParent(const QRectF \&rect) const
Maps the rectangle rect, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped rectangle as a polygon. If the item has no parent, rect will be mapped to the scene's coordinate system.
See also mapToScene(), mapToItem(), mapFromParent(), and The Graphics View Coordinate System.
QPolygonF QGraphicsItem::mapToParent(const QPolygonF \&polygon) const
Maps the polygon polygon, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped polygon. If the item has no parent, polygon will be mapped to the scene's coordinate system.
See also mapToScene(), mapToItem(), mapFromParent(), and The Graphics View Coordinate System.
QPainterPath QGraphicsItem::mapToParent(const QPainterPath \&path) const
Maps the path path, which is in this item's coordinate system, to its parent's coordinate system, and returns the mapped path. If the item has no parent, path will be mapped to the scene's coordinate system.
See also mapToScene(), mapToItem(), mapFromParent(), and The Graphics View Coordinate System.
QPointF QGraphicsItem::mapToParent(qreal x, qreal y) const
This is an overloaded function.
This convenience function is equivalent to calling mapToParent(QPointF(x, y)).
QPolygonF QGraphicsItem::mapToParent(qreal x, qreal y, qreal w, qreal h) const
This convenience function is equivalent to calling mapToParent(QRectF(x, y, w, h)).
This function was introduced in Qt 4.3.
Upstream PySide2 reference signatures (binding differences may apply):
mapToParent(self, path: PySide2.QtGui.QPainterPath) -> PySide2.QtGui.QPainterPath
mapToParent(self, point: PySide2.QtCore.QPointF) -> PySide2.QtCore.QPointF
mapToParent(self, polygon: PySide2.QtGui.QPolygonF) -> PySide2.QtGui.QPolygonF
mapToParent(self, rect: PySide2.QtCore.QRectF) -> PySide2.QtGui.QPolygonF
mapToParent(self, x: float, y: float) -> PySide2.QtCore.QPointF
mapToParent(self, x: float, y: float, w: float, h: float) -> PySide2.QtGui.QPolygonF
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#mapToParent
mapToScene
mapToScene(x: Any, y: Any, w: Any, h: Any) -> Any
X.mapToScene(x, y, w, h) -> PythonQt.QtGui.QPainterPath
Supplemental documentation: Qt 5 reference:
QPointF QGraphicsItem::mapToScene(const QPointF \&point) const
Maps the point point, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped coordinate.
See also mapToItem(), mapToParent(), transform(), mapFromScene(), and The Graphics View Coordinate System.
QPolygonF QGraphicsItem::mapToScene(const QRectF \&rect) const
Maps the rectangle rect, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped rectangle as a polygon.
See also mapToParent(), mapToItem(), mapFromScene(), and The Graphics View Coordinate System.
QPolygonF QGraphicsItem::mapToScene(const QPolygonF \&polygon) const
Maps the polygon polygon, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped polygon.
See also mapToParent(), mapToItem(), mapFromScene(), and The Graphics View Coordinate System.
QPainterPath QGraphicsItem::mapToScene(const QPainterPath \&path) const
Maps the path path, which is in this item's coordinate system, to the scene's coordinate system, and returns the mapped path.
See also mapToParent(), mapToItem(), mapFromScene(), and The Graphics View Coordinate System.
QPointF QGraphicsItem::mapToScene(qreal x, qreal y) const
This is an overloaded function.
This convenience function is equivalent to calling mapToScene(QPointF(x, y)).
QPolygonF QGraphicsItem::mapToScene(qreal x, qreal y, qreal w, qreal h) const
This convenience function is equivalent to calling mapToScene(QRectF(x, y, w, h)).
This function was introduced in Qt 4.3.
Upstream PySide2 reference signatures (binding differences may apply):
mapToScene(self, path: PySide2.QtGui.QPainterPath) -> PySide2.QtGui.QPainterPath
mapToScene(self, point: PySide2.QtCore.QPointF) -> PySide2.QtCore.QPointF
mapToScene(self, polygon: PySide2.QtGui.QPolygonF) -> PySide2.QtGui.QPolygonF
mapToScene(self, rect: PySide2.QtCore.QRectF) -> PySide2.QtGui.QPolygonF
mapToScene(self, x: float, y: float) -> PySide2.QtCore.QPointF
mapToScene(self, x: float, y: float, w: float, h: float) -> PySide2.QtGui.QPolygonF
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#mapToScene
mouseDoubleClickEvent
mouseDoubleClickEvent(event: Any) -> None
X.mouseDoubleClickEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse double-click events for this item.
When doubleclicking an item, the item will first receive a mouse press event, followed by a release event (i.e., a click), then a double-click event, and finally a release event.
Calling QEvent::ignore() or QEvent::accept() on event has no effect.
The default implementation calls mousePressEvent(). If you want to keep the base implementation when reimplementing this function, call QGraphicsItem::mouseDoubleClickEvent() in your reimplementation.
Note that an item will not receive double click events if it is neither selectable nor movable (single mouse clicks are ignored in this case, and that stops the generation of double clicks).
See also mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), and sceneEvent().
Upstream PySide2 reference signatures (binding differences may apply):
mouseDoubleClickEvent(self, event: PySide2.QtWidgets.QGraphicsSceneMouseEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#mouseDoubleClickEvent
mouseMoveEvent
mouseMoveEvent(event: Any) -> None
X.mouseMoveEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse move events for this item. If you do receive this event, you can be certain that this item also received a mouse press event, and that this item is the current mouse grabber.
Calling QEvent::ignore() or QEvent::accept() on event has no effect.
The default implementation handles basic item interaction, such as selection and moving. If you want to keep the base implementation when reimplementing this function, call QGraphicsItem::mouseMoveEvent() in your reimplementation.
Please note that mousePressEvent() decides which graphics item it is that receives mouse events. See the mousePressEvent() description for details.
See also mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), and sceneEvent().
Upstream PySide2 reference signatures (binding differences may apply):
mouseMoveEvent(self, event: PySide2.QtWidgets.QGraphicsSceneMouseEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#mouseMoveEvent
mousePressEvent
mousePressEvent(event: Any) -> None
X.mousePressEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse press events for this item. Mouse press events are only delivered to items that accept the mouse button that is pressed. By default, an item accepts all mouse buttons, but you can change this by calling setAcceptedMouseButtons().
The mouse press event decides which item should become the mouse grabber (see QGraphicsScene::mouseGrabberItem()). If you do not reimplement this function, the press event will propagate to any topmost item beneath this item, and no other mouse events will be delivered to this item.
If you do reimplement this function, event will by default be accepted (see QEvent::accept()), and this item is then the mouse grabber. This allows the item to receive future move, release and double-click events. If you call QEvent::ignore() on event, this item will lose the mouse grab, and event will propagate to any topmost item beneath. No further mouse events will be delivered to this item unless a new mouse press event is received.
The default implementation handles basic item interaction, such as selection and moving. If you want to keep the base implementation when reimplementing this function, call QGraphicsItem::mousePressEvent() in your reimplementation.
The event is QEvent::ignore()d for items that are neither movable nor selectable.
See also mouseMoveEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), and sceneEvent().
Upstream PySide2 reference signatures (binding differences may apply):
mousePressEvent(self, event: PySide2.QtWidgets.QGraphicsSceneMouseEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#mousePressEvent
mouseReleaseEvent
mouseReleaseEvent(event: Any) -> None
X.mouseReleaseEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse release events for this item.
Calling QEvent::ignore() or QEvent::accept() on event has no effect.
The default implementation handles basic item interaction, such as selection and moving. If you want to keep the base implementation when reimplementing this function, call QGraphicsItem::mouseReleaseEvent() in your reimplementation.
Please note that mousePressEvent() decides which graphics item it is that receives mouse events. See the mousePressEvent() description for details.
See also mousePressEvent(), mouseMoveEvent(), mouseDoubleClickEvent(), and sceneEvent().
Upstream PySide2 reference signatures (binding differences may apply):
mouseReleaseEvent(self, event: PySide2.QtWidgets.QGraphicsSceneMouseEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#mouseReleaseEvent
moveBy
moveBy(dx: float, dy: float) -> None
X.moveBy(dx, dy)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::moveBy(qreal dx, qreal dy)
Moves the item by dx points horizontally, and dy point vertically. This function is equivalent to calling setPos(pos() + QPointF(dx, dy)).
Upstream PySide2 reference signatures (binding differences may apply):
moveBy(self, dx: float, dy: float) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#moveBy
opacity
opacity() -> float
X.opacity() -> float
Supplemental documentation: Qt 5 reference:
qreal QGraphicsItem::opacity() const
Returns this item's local opacity, which is between 0.0 (transparent) and 1.0 (opaque). This value is combined with parent and ancestor values into the effectiveOpacity(). The effective opacity decides how the item is rendered and also affects its visibility when queried by functions such as QGraphicsView::items().
The opacity property decides the state of the painter passed to the paint() function. If the item is cached, i.e., ItemCoordinateCache or DeviceCoordinateCache, the effective property will be applied to the item's cache as it is rendered.
The default opacity is 1.0; fully opaque.
This function was introduced in Qt 4.5.
See also setOpacity(), paint(), ItemIgnoresParentOpacity, and ItemDoesntPropagateOpacityToChildren.
Upstream PySide2 reference signatures (binding differences may apply):
opacity(self) -> float
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#opacity
opaqueArea
opaqueArea() -> Any
X.opaqueArea() -> PythonQt.QtGui.QPainterPath
Supplemental documentation: Qt 5 reference:
[virtual] QPainterPath QGraphicsItem::opaqueArea() const
This virtual function returns a shape representing the area where this item is opaque. An area is opaque if it is filled using an opaque brush or color (i.e., not transparent).
This function is used by isObscuredBy(), which is called by underlying items to determine if they are obscured by this item.
The default implementation returns an empty QPainterPath, indicating that this item is completely transparent and does not obscure any other items.
See also isObscuredBy(), isObscured(), and shape().
Upstream PySide2 reference signatures (binding differences may apply):
opaqueArea(self) -> PySide2.QtGui.QPainterPath
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#opaqueArea
paint
paint(painter: Any, option: Any, widget: Any) -> None
X.paint(painter, option, widget)
Supplemental documentation: Qt 5 reference:
[pure virtual] void QGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget \= 0)
This function, which is usually called by QGraphicsView, paints the contents of an item in local coordinates.
Reimplement this function in a QGraphicsItem subclass to provide the item's painting implementation, using painter. The option parameter provides style options for the item, such as its state, exposed area and its level-of-detail hints. The widget argument is optional. If provided, it points to the widget that is being painted on; otherwise, it is 0. For cached painting, widget is always 0.
void RoundRectItem::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
}
The painter's pen is 0-width by default, and its pen is initialized to the QPalette::Text brush from the paint device's palette. The brush is initialized to QPalette::Window.
Make sure to constrain all painting inside the boundaries of boundingRect() to avoid rendering artifacts (as QGraphicsView does not clip the painter for you). In particular, when QPainter renders the outline of a shape using an assigned QPen, half of the outline will be drawn outside, and half inside, the shape you're rendering (e.g., with a pen width of 2 units, you must draw outlines 1 unit inside boundingRect()). QGraphicsItem does not support use of cosmetic pens with a non-zero width.
All painting is done in local coordinates.
Note: It is mandatory that an item will always redraw itself in the exact same way, unless update() was called; otherwise visual artifacts may occur. In other words, two subsequent calls to paint() must always produce the same output, unless update() was called between them.
Note: Enabling caching for an item does not guarantee that paint() will be invoked only once by the Graphics View framework, even without any explicit call to update(). See the documentation of setCacheMode() for more details.
See also setCacheMode(), QPen::width(), Item Coordinates, and ItemUsesExtendedStyleOption.
Upstream PySide2 reference signatures (binding differences may apply):
paint(self, painter: PySide2.QtGui.QPainter, option: PySide2.QtWidgets.QStyleOptionGraphicsItem, widget: typing.Optional[PySide2.QtWidgets.QWidget]=...) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#paint
panel
panel() -> Any
X.panel() -> PythonQt.QtGui.QGraphicsItem
Supplemental documentation: Qt 5 reference:
QGraphicsItem *QGraphicsItem::panel() const
Returns the item's panel, or nullptr if this item does not have a panel. If the item
is a panel, it will return itself. Otherwise it will return the closest ancestor that is
a panel.
This function was introduced in Qt 4.6.
See also isPanel() and ItemIsPanel.
Upstream PySide2 reference signatures (binding differences may apply):
panel(self) -> PySide2.QtWidgets.QGraphicsItem
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#panel
panelModality
panelModality() -> Any
X.panelModality()
Supplemental documentation: Qt 5 reference:
QGraphicsItem::PanelModality QGraphicsItem::panelModality() const
Returns the modality for this item.
This function was introduced in Qt 4.6.
See also setPanelModality().
Upstream PySide2 reference signatures (binding differences may apply):
panelModality(self) -> PySide2.QtWidgets.QGraphicsItem.PanelModality
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#panelModality
parentItem
parentItem() -> Any
X.parentItem() -> PythonQt.QtGui.QGraphicsItem
Supplemental documentation: Qt 5 reference:
QGraphicsItem *QGraphicsItem::parentItem() const
Returns a pointer to this item's parent item. If this item does not have a parent,
nullptr is returned.
See also setParentItem() and childItems().
Upstream PySide2 reference signatures (binding differences may apply):
parentItem(self) -> PySide2.QtWidgets.QGraphicsItem
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#parentItem
parentObject
parentObject() -> Any
X.parentObject() -> PythonQt.QtGui.QGraphicsObject
Supplemental documentation: Qt 5 reference:
QGraphicsObject *QGraphicsItem::parentObject() const
Returns a pointer to the item's parent, cast to a
QGraphicsObject. Returns
nullptr if the parent item is not a
QGraphicsObject.
This function was introduced in Qt 4.6.
See also parentItem() and childItems().
Upstream PySide2 reference signatures (binding differences may apply):
parentObject(self) -> PySide2.QtWidgets.QGraphicsObject
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#parentObject
parentWidget
parentWidget() -> Any
X.parentWidget() -> PythonQt.QtGui.QGraphicsWidget
Supplemental documentation: Qt 5 reference:
QGraphicsWidget *QGraphicsItem::parentWidget() const
Returns a pointer to the item's parent widget. The item's parent widget is the closest parent item that is a widget.
This function was introduced in Qt 4.4.
See also parentItem() and childItems().
Upstream PySide2 reference signatures (binding differences may apply):
parentWidget(self) -> PySide2.QtWidgets.QGraphicsWidget
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#parentWidget
pos
pos() -> Any
X.pos() -> PythonQt.QtCore.QPointF
Supplemental documentation: Qt 5 reference:
QPointF QGraphicsItem::pos() const
Returns the position of the item in parent coordinates. If the item has no parent, its position is given in scene coordinates.
The position of the item describes its origin (local coordinate (0, 0)) in parent coordinates; this function returns the same as mapToParent(0, 0).
For convenience, you can also call scenePos() to determine the item's position in scene coordinates, regardless of its parent.
See also x(), y(), setPos(), transform(), and The Graphics View Coordinate System.
Upstream PySide2 reference signatures (binding differences may apply):
pos(self) -> PySide2.QtCore.QPointF
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#pos
prepareGeometryChange
prepareGeometryChange() -> None
X.prepareGeometryChange()
Supplemental documentation: Qt 5 reference:
[protected] void QGraphicsItem::prepareGeometryChange()
Prepares the item for a geometry change. Call this function before changing the bounding rect of an item to keep QGraphicsScene's index up to date.
prepareGeometryChange() will call update() if this is necessary.
Example:
void CircleItem::setRadius(qreal newRadius)
{
if (radius != newRadius) {
prepareGeometryChange();
radius = newRadius;
}
}
See also boundingRect().
Upstream PySide2 reference signatures (binding differences may apply):
prepareGeometryChange(self) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#prepareGeometryChange
removeFromIndex
removeFromIndex() -> None
X.removeFromIndex()
Upstream PySide2 reference signatures (binding differences may apply):
removeFromIndex(self) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#removeFromIndex
removeSceneEventFilter
removeSceneEventFilter(filterItem: Any) -> None
X.removeSceneEventFilter(filterItem)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::removeSceneEventFilter(QGraphicsItem *filterItem)
Removes an event filter on this item from filterItem.
See also installSceneEventFilter().
Upstream PySide2 reference signatures (binding differences may apply):
removeSceneEventFilter(self, filterItem: PySide2.QtWidgets.QGraphicsItem) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#removeSceneEventFilter
resetTransform
resetTransform() -> None
X.resetTransform()
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::resetTransform()
Resets this item's transformation matrix to the identity matrix or all the
transformation properties to their default values. This is equivalent to calling
setTransform(QTransform()).
This function was introduced in Qt 4.3.
See also setTransform() and transform().
Upstream PySide2 reference signatures (binding differences may apply):
resetTransform(self) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#resetTransform
rotation
rotation() -> float
X.rotation() -> float
Supplemental documentation: Qt 5 reference:
qreal QGraphicsItem::rotation() const
Returns the clockwise rotation, in degrees, around the Z axis. The default value is 0 (i.e., the item is not rotated).
The rotation is combined with the item's scale(), transform() and transformations() to map the item's coordinate system to the parent item.
This function was introduced in Qt 4.6.
See also setRotation(), transformOriginPoint(), and Transformations.
Upstream PySide2 reference signatures (binding differences may apply):
rotation(self) -> float
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#rotation
scale
scale() -> float
X.scale() -> float
Supplemental documentation: Qt 5 reference:
qreal QGraphicsItem::scale() const
Returns the scale factor of the item. The default scale factor is 1.0 (i.e., the item is not scaled).
The scale is combined with the item's rotation(), transform() and transformations() to map the item's coordinate system to the parent item.
This function was introduced in Qt 4.6.
See also setScale(), rotation(), and Transformations.
Upstream PySide2 reference signatures (binding differences may apply):
scale(self) -> float
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#scale
scene
scene() -> Any
X.scene() -> PythonQt.QtGui.QGraphicsScene
Supplemental documentation: Qt 5 reference:
QGraphicsScene *QGraphicsItem::scene() const
Returns the current scene for the item, or nullptr if the item is not stored in a
scene.
To add or move an item to a scene, call QGraphicsScene::addItem().
Upstream PySide2 reference signatures (binding differences may apply):
scene(self) -> PySide2.QtWidgets.QGraphicsScene
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#scene
sceneBoundingRect
sceneBoundingRect() -> Any
X.sceneBoundingRect() -> PythonQt.QtCore.QRectF
Supplemental documentation: Qt 5 reference:
QRectF QGraphicsItem::sceneBoundingRect() const
Returns the bounding rect of this item in scene coordinates, by combining sceneTransform() with boundingRect().
See also boundingRect() and The Graphics View Coordinate System.
Upstream PySide2 reference signatures (binding differences may apply):
sceneBoundingRect(self) -> PySide2.QtCore.QRectF
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#sceneBoundingRect
sceneEvent
sceneEvent(event: Any) -> bool
X.sceneEvent(event) -> bool
Supplemental documentation: Qt 5 reference:
[virtual protected] bool QGraphicsItem::sceneEvent(QEvent *event)
This virtual function receives events to this item. Reimplement this function to intercept events before they are dispatched to the specialized event handlers contextMenuEvent(), focusInEvent(), focusOutEvent(), hoverEnterEvent(), hoverMoveEvent(), hoverLeaveEvent(), keyPressEvent(), keyReleaseEvent(), mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), and mouseDoubleClickEvent().
Returns true if the event was recognized and handled; otherwise, (e.g., if the event
type was not recognized,) false is returned.
event is the intercepted event.
Upstream PySide2 reference signatures (binding differences may apply):
sceneEvent(self, event: PySide2.QtCore.QEvent) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#sceneEvent
sceneEventFilter
sceneEventFilter(watched: Any, event: Any) -> bool
X.sceneEventFilter(watched, event) -> bool
Supplemental documentation: Qt 5 reference:
[virtual protected] bool QGraphicsItem::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
Filters events for the item watched. event is the filtered event.
Reimplementing this function in a subclass makes it possible for the item to be used as an event filter for other items, intercepting all the events sent to those items before they are able to respond.
Reimplementations must return true to prevent further processing of a given event, ensuring that it will not be delivered to the watched item, or return false to indicate that the event should be propagated further by the event system.
See also installSceneEventFilter().
Upstream PySide2 reference signatures (binding differences may apply):
sceneEventFilter(self, watched: PySide2.QtWidgets.QGraphicsItem, event: PySide2.QtCore.QEvent) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#sceneEventFilter
scenePos
scenePos() -> Any
X.scenePos() -> PythonQt.QtCore.QPointF
Supplemental documentation: Qt 5 reference:
QPointF QGraphicsItem::scenePos() const
Returns the item's position in scene coordinates. This is equivalent to calling
mapToScene(0, 0).
See also pos(), sceneTransform(), and The Graphics View Coordinate System.
Upstream PySide2 reference signatures (binding differences may apply):
scenePos(self) -> PySide2.QtCore.QPointF
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#scenePos
sceneTransform
sceneTransform() -> Any
X.sceneTransform() -> PythonQt.QtGui.QTransform
Supplemental documentation: Qt 5 reference:
QTransform QGraphicsItem::sceneTransform() const
Returns this item's scene transformation matrix. This matrix can be used to map coordinates and geometrical shapes from this item's local coordinate system to the scene's coordinate system. To map coordinates from the scene, you must first invert the returned matrix.
Example:
QGraphicsRectItem rect;
rect.setPos(100, 100);
rect.sceneTransform().map(QPointF(0, 0));
// returns QPointF(100, 100);
rect.sceneTransform().inverted().map(QPointF(100, 100));
// returns QPointF(0, 0);
Unlike transform(), which returns only an item's local transformation, this function includes the item's (and any parents') position, and all the transformation properties.
This function was introduced in Qt 4.3.
See also transform(), setTransform(), scenePos(), The Graphics View Coordinate System, and Transformations.
Upstream PySide2 reference signatures (binding differences may apply):
sceneTransform(self) -> PySide2.QtGui.QTransform
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#sceneTransform
scroll
scroll(dx: float, dy: float, rect: Any) -> None
X.scroll(dx, dy, rect)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF \&rect \= QRectF())
Scrolls the contents of rect by dx, dy. If rect is a null rect (the default), the item's bounding rect is scrolled.
Scrolling provides a fast alternative to simply redrawing when the contents of the item (or parts of the item) are shifted vertically or horizontally. Depending on the current transformation and the capabilities of the paint device (i.e., the viewport), this operation may consist of simply moving pixels from one location to another using memmove(). In most cases this is faster than rerendering the entire area.
After scrolling, the item will issue an update for the newly exposed areas. If scrolling is not supported (e.g., you are rendering to an OpenGL viewport, which does not benefit from scroll optimizations), this function is equivalent to calling update(rect).
Note: Scrolling is only supported when QGraphicsItem::ItemCoordinateCache is enabled; in all other cases calling this function is equivalent to calling update(rect). If you for sure know that the item is opaque and not overlapped by other items, you can map the rect to viewport coordinates and scroll the viewport.
QTransform xform = item->deviceTransform(view->viewportTransform());
QRect deviceRect = xform.mapRect(rect).toAlignedRect();
view->viewport()->scroll(dx, dy, deviceRect);
This function was introduced in Qt 4.4.
See also boundingRect().
Upstream PySide2 reference signatures (binding differences may apply):
scroll(self, dx: float, dy: float, rect: PySide2.QtCore.QRectF=...) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#scroll
setAcceptDrops
setAcceptDrops(on: bool) -> None
X.setAcceptDrops(on)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::setAcceptDrops(bool on)
If on is true, this item will accept drag and drop events; otherwise, it is transparent for drag and drop events. By default, items do not accept drag and drop events.
See also acceptDrops().
Upstream PySide2 reference signatures (binding differences may apply):
setAcceptDrops(self, on: bool) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#setAcceptDrops
setAcceptHoverEvents
setAcceptHoverEvents(enabled: bool) -> None
X.setAcceptHoverEvents(enabled)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::setAcceptHoverEvents(bool enabled)
If enabled is true, this item will accept hover events; otherwise, it will ignore them. By default, items do not accept hover events.
Hover events are delivered when there is no current mouse grabber item. They are sent when the mouse cursor enters an item, when it moves around inside the item, and when the cursor leaves an item. Hover events are commonly used to highlight an item when it's entered, and for tracking the mouse cursor as it hovers over the item (equivalent to QWidget::mouseTracking).
Parent items receive hover enter events before their children, and leave events after their children. The parent does not receive a hover leave event if the cursor enters a child, though; the parent stays "hovered" until the cursor leaves its area, including its children's areas.
If a parent item handles child events, it will receive hover move, drag move, and drop events as the cursor passes through its children, but it does not receive hover enter and hover leave, nor drag enter and drag leave events on behalf of its children.
A QGraphicsWidget with window decorations will accept hover events regardless of the value of acceptHoverEvents().
This function was introduced in Qt 4.4.
See also acceptHoverEvents(), hoverEnterEvent(), hoverMoveEvent(), and hoverLeaveEvent().
Upstream PySide2 reference signatures (binding differences may apply):
setAcceptHoverEvents(self, enabled: bool) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#setAcceptHoverEvents
setAcceptTouchEvents
setAcceptTouchEvents(enabled: bool) -> None
X.setAcceptTouchEvents(enabled)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::setAcceptTouchEvents(bool enabled)
If enabled is true, this item will accept touch events; otherwise, it will ignore them. By default, items do not accept touch events.
This function was introduced in Qt 4.6.
See also acceptTouchEvents().
Upstream PySide2 reference signatures (binding differences may apply):
setAcceptTouchEvents(self, enabled: bool) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#setAcceptTouchEvents
setAcceptedMouseButtons
setAcceptedMouseButtons(buttons: Any) -> None
X.setAcceptedMouseButtons(buttons)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::setAcceptedMouseButtons(Qt::MouseButtons buttons)
Sets the mouse buttons that this item accepts mouse events for.
By default, all mouse buttons are accepted. If an item accepts a mouse button, it will become the mouse grabber item when a mouse press event is delivered for that button. However, if the item does not accept the mouse button, QGraphicsScene will forward the mouse events to the first item beneath it that does.
To disable mouse events for an item (i.e., make it transparent for mouse events), call setAcceptedMouseButtons(0).
See also acceptedMouseButtons() and mousePressEvent().
Upstream PySide2 reference signatures (binding differences may apply):
setAcceptedMouseButtons(self, buttons: PySide2.QtCore.Qt.MouseButtons) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#setAcceptedMouseButtons
setActive
setActive(active: bool) -> None
X.setActive(active)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::setActive(bool active)
If active is true, and the scene is active, this item's panel will be activated. Otherwise, the panel is deactivated.
If the item is not part of an active scene, active will decide what happens to the panel when the scene becomes active or the item is added to the scene. If true, the item's panel will be activated when the item is either added to the scene or the scene is activated. Otherwise, the item will stay inactive independent of the scene's activated state.
This function was introduced in Qt 4.6.
See also isPanel(), QGraphicsScene::setActivePanel(), and QGraphicsScene::isActive().
Upstream PySide2 reference signatures (binding differences may apply):
setActive(self, active: bool) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#setActive
setBoundingRegionGranularity
setBoundingRegionGranularity(granularity: float) -> None
X.setBoundingRegionGranularity(granularity)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)
Sets the bounding region granularity to granularity; a value between and including 0 and 1. The default value is 0 (i.e., the lowest granularity, where the bounding region corresponds to the item's bounding rectangle).
The granularity is used by boundingRegion() to calculate how fine the bounding region of the item should be. The highest achievable granularity is 1, where boundingRegion() will return the finest outline possible for the respective device (e.g., for a QGraphicsView viewport, this gives you a pixel-perfect bounding region). The lowest possible granularity is 0. The value of granularity describes the ratio between device resolution and the resolution of the bounding region (e.g., a value of 0.25 will provide a region where each chunk corresponds to 4x4 device units / pixels).
This function was introduced in Qt 4.4.
See also boundingRegionGranularity().
Upstream PySide2 reference signatures (binding differences may apply):
setBoundingRegionGranularity(self, granularity: float) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#setBoundingRegionGranularity
setCacheMode
setCacheMode(mode: Any, cacheSize: Any) -> None
X.setCacheMode(mode, cacheSize)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::setCacheMode(QGraphicsItem::CacheMode mode, const QSize \&logicalCacheSize \= QSize())
Sets the item's cache mode to mode.
The optional logicalCacheSize argument is used only by ItemCoordinateCache mode, and describes the resolution of the cache buffer; if logicalCacheSize is (100, 100), QGraphicsItem will fit the item into 100x100 pixels in graphics memory, regardless of the logical size of the item itself. By default QGraphicsItem uses the size of boundingRect(). For all other cache modes than ItemCoordinateCache, logicalCacheSize is ignored.
Caching can speed up rendering if your item spends a significant time redrawing itself. In some cases the cache can also slow down rendering, in particular when the item spends less time redrawing than QGraphicsItem spends redrawing from the cache.
When caching is enabled, an item's paint() function will generally draw into an offscreen pixmap cache; for any subsequent repaint requests, the Graphics View framework will redraw from the cache. This approach works particularly well with QGLWidget, which stores all the cache as OpenGL textures.
Be aware that QPixmapCache's cache limit may need to be changed to obtain optimal performance.
You can read more about the different cache modes in the CacheMode documentation.
Note: Enabling caching does not imply that the item's paint() function will be called only in response to an explicit update() call. For instance, under memory pressure, Qt may decide to drop some of the cache information; in such cases an item's paint() function will be called even if there was no update() call (that is, exactly as if there were no caching enabled).
This function was introduced in Qt 4.4.
See also cacheMode(), CacheMode, and QPixmapCache::setCacheLimit().
Upstream PySide2 reference signatures (binding differences may apply):
setCacheMode(self, mode: PySide2.QtWidgets.QGraphicsItem.CacheMode, cacheSize: PySide2.QtCore.QSize=...) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#setCacheMode
setCursor
setCursor(cursor: Any) -> None
X.setCursor(cursor)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::setCursor(const QCursor \&cursor)
Sets the current cursor shape for the item to cursor. The mouse cursor will assume this shape when it's over this item. See the list of predefined cursor objects for a range of useful shapes.
An editor item might want to use an I-beam cursor:
item->setCursor(Qt::IBeamCursor);
If no cursor has been set, the cursor of the item beneath is used.
See also cursor(), hasCursor(), unsetCursor(), QWidget::cursor, and QGuiApplication::overrideCursor().
Upstream PySide2 reference signatures (binding differences may apply):
setCursor(self, cursor: PySide2.QtGui.QCursor) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#setCursor
setData
setData(key: int, value: Any) -> None
X.setData(key, value)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::setData(int key, const QVariant \&value)
Sets this item's custom data for the key key to value.
Custom item data is useful for storing arbitrary properties for any item. Qt does not use this feature for storing data; it is provided solely for the convenience of the user.
See also data().
Upstream PySide2 reference signatures (binding differences may apply):
setData(self, key: int, value: typing.Any) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#setData
setEnabled
setEnabled(enabled: bool) -> None
X.setEnabled(enabled)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::setEnabled(bool enabled)
If enabled is true, the item is enabled; otherwise, it is disabled.
Disabled items are visible, but they do not receive any events, and cannot take focus nor be selected. Mouse events are discarded; they are not propagated unless the item is also invisible, or if it does not accept mouse events (see acceptedMouseButtons()). A disabled item cannot become the mouse grabber, and as a result of this, an item loses the grab if it becomes disabled when grabbing the mouse, just like it loses focus if it had focus when it was disabled.
Disabled items are traditionally drawn using grayed-out colors (see QPalette::Disabled).
If you disable a parent item, all its children will also be disabled. If you enable a parent item, all children will be enabled, unless they have been explicitly disabled (i.e., if you call setEnabled(false) on a child, it will not be re-enabled if its parent is disabled, and then enabled again).
Items are enabled by default.
Note: If you install an event filter, you can still intercept events before they are delivered to items; this mechanism disregards the item's enabled state.
See also isEnabled().
Upstream PySide2 reference signatures (binding differences may apply):
setEnabled(self, enabled: bool) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#setEnabled
setFiltersChildEvents
setFiltersChildEvents(enabled: bool) -> None
X.setFiltersChildEvents(enabled)
Supplemental documentation: Qt 5 reference:
void QGraphicsItem::setFiltersChildEvents(bool enabled)
If enabled is true, this item is set to filter all events for all its children (i.e., all events intented for any of its children are instead sent to this item); otherwise, if enabled is false, this item will only handle its own events. The default value is false.
This function was introduced in Qt 4.6.
See also filtersChildEvents().
Upstream PySide2 reference signatures (binding differences may apply):
setFiltersChildEvents(self, enabled: bool) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsitem.html#setFiltersChildEvents