PythonQt.QtGui.QGraphicsScene · declarations 002
Back to PythonQt.QtGui.QGraphicsScene
event
event(event: Any) -> bool
X.event(event) -> bool
Supplemental documentation: Qt 5 reference:
[override virtual protected] bool QGraphicsScene::event(QEvent *event)
Reimplements: QObject::event(QEvent *e).
Processes the event event, and dispatches it to the respective event handlers.
In addition to calling the convenience event handlers, this function is responsible for converting mouse move events to hover events for when there is no mouse grabber item. Hover events are delivered directly to items; there is no convenience function for them.
Unlike QWidget, QGraphicsScene does not have the convenience functions enterEvent() and leaveEvent(). Use this function to obtain those events instead.
Returns true if event has been recognized and processed; otherwise, returns false.
See also contextMenuEvent(), keyPressEvent(), keyReleaseEvent(), mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), focusInEvent(), and focusOutEvent().
Upstream PySide2 reference signatures (binding differences may apply):
event(self, event: PySide2.QtCore.QEvent) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#event
eventFilter
eventFilter(watched: Any, event: Any) -> bool
X.eventFilter(watched, event) -> bool
Supplemental documentation: Qt 5 reference:
[override virtual protected] bool QGraphicsScene::eventFilter(QObject *watched, QEvent *event)
Reimplements: QObject::eventFilter(QObject *watched, QEvent *event).
QGraphicsScene filters QApplication's events to detect palette and font changes.
Upstream PySide2 reference signatures (binding differences may apply):
eventFilter(self, watched: PySide2.QtCore.QObject, event: PySide2.QtCore.QEvent) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#eventFilter
focusInEvent
focusInEvent(event: Any) -> None
X.focusInEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsScene::focusInEvent(QFocusEvent *focusEvent)
This event handler, for event focusEvent, can be reimplemented in a subclass to receive focus in events.
The default implementation sets focus on the scene, and then on the last focus item.
See also QGraphicsItem::focusOutEvent().
Upstream PySide2 reference signatures (binding differences may apply):
focusInEvent(self, event: PySide2.QtGui.QFocusEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#focusInEvent
focusItem
focusItem() -> Any
X.focusItem() -> PythonQt.QtGui.QGraphicsItem
Supplemental documentation: Qt 5 reference:
QGraphicsItem *QGraphicsScene::focusItem() const
When the scene is active, this functions returns the scene's current focus item, or
nullptr if no item currently has focus. When the scene is inactive, this functions
returns the item that will gain input focus when the scene becomes active.
The focus item receives keyboard input when the scene receives a key event.
See also setFocusItem(), QGraphicsItem::hasFocus(), and isActive().
Upstream PySide2 reference signatures (binding differences may apply):
focusItem(self) -> PySide2.QtWidgets.QGraphicsItem
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#focusItem
focusItemChanged
focusItemChanged(*args: Any, **kwargs: Any) -> Any
Native PythonQt.QtGui.QGraphicsScene.focusItemChanged; argument details are not documented.
Supplemental documentation: Qt 5 reference:
[signal] void QGraphicsScene::focusItemChanged(QGraphicsItem *newFocusItem, QGraphicsItem *oldFocusItem, Qt::FocusReason reason)
This signal is emitted by QGraphicsScene whenever focus changes in the scene (i.e., when an item gains or loses input focus, or when focus passes from one item to another). You can connect to this signal if you need to keep track of when other items gain input focus. It is particularly useful for implementing virtual keyboards, input methods, and cursor items.
oldFocusItem is a pointer to the item that previously had focus, or 0 if no item had
focus before the signal was emitted. newFocusItem is a pointer to the item that gained
input focus, or nullptr if focus was lost. reason is the reason for the focus change
(e.g., if the scene was deactivated while an input field had focus, oldFocusItem would
point to the input field item, newFocusItem would be nullptr, and reason would be
Qt::ActiveWindowFocusReason.
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#focusItemChanged
focusOnTouch
instance-attribute
focusOnTouch: bool
Qt 5 reference:
focusOnTouch : bool
This property holds whether items gain focus when receiving a touch begin event.
The usual behavior is to transfer focus only when an item is clicked. Often a tap on a touchpad is interpreted as equivalent to a mouse click by the operating system, generating a synthesized click event in response. However, at least on macOS you can configure this behavior.
By default, QGraphicsScene also transfers focus when you touch on a trackpad or similar. If the operating system is configured to not generate a synthetic mouse click on tapping the trackpad, this is surprising. If the operating system does generate synthetic mouse clicks on tapping the trackpad, the focus transfer on starting a touch gesture is unnecessary.
With focusOnTouch switched off, QGraphicsScene behaves as one would expect on macOS.
The default value is true, ensuring that the default behavior is just as in Qt
versions prior to 5.12. Set to false to prevent touch events from triggering focus
changes.
This property was introduced in Qt 5.12.
Access functions:
| bool | focusOnTouch() const |
|---|---|
| void | setFocusOnTouch(bool enabled) |
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#focusOnTouch
focusOutEvent
focusOutEvent(event: Any) -> None
X.focusOutEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent)
This event handler, for event focusEvent, can be reimplemented in a subclass to receive focus out events.
The default implementation removes focus from any focus item, then removes focus from the scene.
See also QGraphicsItem::focusInEvent().
Upstream PySide2 reference signatures (binding differences may apply):
focusOutEvent(self, event: PySide2.QtGui.QFocusEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#focusOutEvent
font
instance-attribute
font: QFont
Qt 5 reference:
font : QFont
This property holds the scene's default font
This property provides the scene's font. The scene font defaults to, and resolves all its entries from, QApplication::font.
If the scene's font changes, either directly through setFont() or indirectly when the application font changes, QGraphicsScene first sends itself a FontChange event, and it then sends FontChange events to all top-level widget items in the scene. These items respond by resolving their own fonts to the scene, and they then notify their children, who again notify their children, and so on, until all widget items have updated their fonts.
Changing the scene font, (directly or indirectly through QApplication::setFont(),) automatically schedules a redraw the entire scene.
This property was introduced in Qt 4.4.
Access functions:
| QFont | font() const |
|---|---|
| void | setFont(const QFont \&font) |
See also QWidget::font, QApplication::setFont(), palette, and style().
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#font
foregroundBrush
instance-attribute
foregroundBrush: QBrush
Qt 5 reference:
foregroundBrush : QBrush
This property holds the foreground brush of the scene.
Change this property to set the scene's foreground to a different color, gradient or texture.
The foreground is drawn after (on top of) the items. The default foreground brush is Qt::NoBrush ( i.e. the foreground is not drawn).
Example:
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
// a white semi-transparent foreground
scene.setForegroundBrush(QColor(255, 255, 255, 127));
// a grid foreground
scene.setForegroundBrush(QBrush(Qt::lightGray, Qt::CrossPattern));
QGraphicsScene::render() calls drawForeground() to draw the scene foreground. For more detailed control over how the foreground is drawn, you can reimplement the drawForeground() function in a QGraphicsScene subclass.
Access functions:
| QBrush | foregroundBrush() const |
|---|---|
| void | setForegroundBrush(const QBrush \&brush) |
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#foregroundBrush
hasFocus
hasFocus() -> bool
X.hasFocus() -> bool
Supplemental documentation: Qt 5 reference:
bool QGraphicsScene::hasFocus() const
Returns true if the scene has focus; otherwise returns false. If the scene has
focus, it will will forward key events from
QKeyEvent to any item that has
focus.
See also setFocus() and setFocusItem().
Upstream PySide2 reference signatures (binding differences may apply):
hasFocus(self) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#hasFocus
height
height() -> float
X.height() -> float
Supplemental documentation: Qt 5 reference:
qreal QGraphicsScene::height() const
This convenience function is equivalent to calling sceneRect().height().
See also width().
Upstream PySide2 reference signatures (binding differences may apply):
height(self) -> float
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#height
helpEvent
helpEvent(event: Any) -> None
X.helpEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent)
This event handler, for event helpEvent, can be reimplemented in a subclass to receive help events. The events are of type QEvent::ToolTip, which are created when a tooltip is requested.
The default implementation shows the tooltip of the topmost visible item, i.e., the item with the highest z-value, at the mouse cursor position. If no item has a tooltip set, this function does nothing.
Note: See items() for a definition of which items are considered visible by this function.
See also QGraphicsItem::toolTip() and QGraphicsSceneHelpEvent.
Upstream PySide2 reference signatures (binding differences may apply):
helpEvent(self, event: PySide2.QtWidgets.QGraphicsSceneHelpEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#helpEvent
inputMethodEvent
inputMethodEvent(event: Any) -> None
X.inputMethodEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsScene::inputMethodEvent(QInputMethodEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive input method events for the scene.
The default implementation forwards the event to the focusItem(). If no item currently has focus or the current focus item does not accept input methods, this function does nothing.
See also QGraphicsItem::inputMethodEvent().
Upstream PySide2 reference signatures (binding differences may apply):
inputMethodEvent(self, event: PySide2.QtGui.QInputMethodEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#inputMethodEvent
inputMethodQuery
inputMethodQuery(query: Any) -> Any
X.inputMethodQuery(query) -> object
Supplemental documentation: Qt 5 reference:
[virtual] QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const
This method is used by input methods to query a set of properties of the scene to be able to support complex input method operations as support for surrounding text and reconversions.
The query parameter specifies which property is queried.
See also QWidget::inputMethodQuery().
Upstream PySide2 reference signatures (binding differences may apply):
inputMethodQuery(self, query: PySide2.QtCore.Qt.InputMethodQuery) -> typing.Any
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#inputMethodQuery
invalidate
invalidate(x: Any, y: Any, w: Any, h: Any, layers: Any) -> None
X.invalidate(x, y, w, h, layers)
Supplemental documentation: Qt 5 reference:
[slot] void QGraphicsScene::invalidate(const QRectF \&rect \= QRectF(), QGraphicsScene::SceneLayers layers \= AllLayers)
Invalidates and schedules a redraw of the layers in rect on the scene. Any cached content in layers is unconditionally invalidated and redrawn.
You can use this function overload to notify QGraphicsScene of changes to the background or the foreground of the scene. This function is commonly used for scenes with tile-based backgrounds to notify changes when QGraphicsView has enabled CacheBackground.
Example:
QRectF TileScene::rectForTile(int x, int y) const
{
// Return the rectangle for the tile at position (x, y).
return QRectF(x * tileWidth, y * tileHeight, tileWidth, tileHeight);
}
void TileScene::setTile(int x, int y, const QPixmap &pixmap)
{
// Sets or replaces the tile at position (x, y) with pixmap.
if (x >= 0 && x < numTilesH && y >= 0 && y < numTilesV) {
tiles[y][x] = pixmap;
invalidate(rectForTile(x, y), BackgroundLayer);
}
}
void TileScene::drawBackground(QPainter *painter, const QRectF &exposed)
{
// Draws all tiles that intersect the exposed area.
for (int y = 0; y < numTilesV; ++y) {
for (int x = 0; x < numTilesH; ++x) {
QRectF rect = rectForTile(x, y);
if (exposed.intersects(rect))
painter->drawPixmap(rect.topLeft(), tiles[y][x]);
}
}
}
Note that QGraphicsView currently supports background caching only (see QGraphicsView::CacheBackground). This function is equivalent to calling update() if any layer but BackgroundLayer is passed.
See also QGraphicsView::resetCachedContent().
void QGraphicsScene::invalidate(qreal x, qreal y, qreal w, qreal h, QGraphicsScene::SceneLayers layers \= ...)
This is an overloaded function.
This convenience function is equivalent to calling invalidate(QRectF(x, y, w, h), layers);
This function was introduced in Qt 4.3.
Upstream PySide2 reference signatures (binding differences may apply):
invalidate(self, rect: PySide2.QtCore.QRectF=..., layers: PySide2.QtWidgets.QGraphicsScene.SceneLayers=...) -> None
invalidate(self, x: float, y: float, w: float, h: float, layers: PySide2.QtWidgets.QGraphicsScene.SceneLayers=...) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#invalidate
isActive
isActive() -> bool
X.isActive() -> bool
Supplemental documentation: Qt 5 reference:
bool QGraphicsScene::isActive() const
Returns true if the scene is active (e.g., it's viewed by at least one
QGraphicsView that is active);
otherwise returns false.
This function was introduced in Qt 4.6.
See also QGraphicsItem::isActive() and QWidget::isActiveWindow().
Upstream PySide2 reference signatures (binding differences may apply):
isActive(self) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#isActive
isSortCacheEnabled
isSortCacheEnabled() -> bool
X.isSortCacheEnabled() -> bool
Upstream PySide2 reference signatures (binding differences may apply):
isSortCacheEnabled(self) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#isSortCacheEnabled
itemAt
itemAt(x: Any, y: Any, deviceTransform: Any) -> Any
X.itemAt(x, y, deviceTransform) -> PythonQt.QtGui.QGraphicsItem
Supplemental documentation: Qt 5 reference:
QGraphicsItem *QGraphicsScene::itemAt(const QPointF \&position, const QTransform \&deviceTransform) const
Returns the topmost visible item at the specified position, or nullptr if there are
no items at this position.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
Note: See items() for a definition of which items are considered visible by this function.
This function was introduced in Qt 4.6.
See also items(), collidingItems(), and Sorting.
QGraphicsItem *QGraphicsScene::itemAt(qreal x, qreal y, const QTransform \&deviceTransform) const
This is an overloaded function.
Returns the topmost visible item at the position specified by (x, y), or nullptr
if there are no items at this position.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
This convenience function is equivalent to calling itemAt(QPointF(x, y),
deviceTransform).
Note: See items() for a definition of which items are considered visible by this function.
This function was introduced in Qt 4.6.
Upstream PySide2 reference signatures (binding differences may apply):
itemAt(self, pos: PySide2.QtCore.QPointF, deviceTransform: PySide2.QtGui.QTransform) -> PySide2.QtWidgets.QGraphicsItem
itemAt(self, x: float, y: float, deviceTransform: PySide2.QtGui.QTransform) -> PySide2.QtWidgets.QGraphicsItem
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#itemAt
itemIndexMethod
instance-attribute
itemIndexMethod: Any
Qt 5 reference:
itemIndexMethod : ItemIndexMethod
This property holds the item indexing method.
QGraphicsScene applies an indexing algorithm to the scene, to speed up item discovery functions like items() and itemAt(). Indexing is most efficient for static scenes (i.e., where items don't move around). For dynamic scenes, or scenes with many animated items, the index bookkeeping can outweigh the fast lookup speeds.
For the common case, the default index method
BspTreeIndex
works fine. If your scene uses many animations and you are experiencing slowness, you
can disable indexing by calling setItemIndexMethod(NoIndex).
Access functions:
| QGraphicsScene::ItemIndexMethod | itemIndexMethod() const |
|---|---|
| void | setItemIndexMethod(QGraphicsScene::ItemIndexMethod method) |
See also bspTreeDepth.
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#itemIndexMethod
items
items(x: Any, y: Any, w: Any, h: Any, mode: Any, order: Any, deviceTransform: Any) -> tuple
X.items(x, y, w, h, mode, order, deviceTransform) -> tuple
Supplemental documentation: Qt 5 reference:
QList\<QGraphicsItem *> QGraphicsScene::items(Qt::SortOrder order \= Qt::DescendingOrder) const
Returns an ordered list of all items on the scene. order decides the stacking order.
See also addItem(), removeItem(), and Sorting.
QList\<QGraphicsItem *> QGraphicsScene::items(const QPointF \&pos, Qt::ItemSelectionMode mode \= Qt::IntersectsItemShape, Qt::SortOrder order \= Qt::DescendingOrder, const QTransform \&deviceTransform \= QTransform()) const
Returns all visible items that, depending on mode, are at the specified pos in a
list sorted using order. In this case, "visible" defines items for which: isVisible()
returns true, effectiveOpacity() returns a value greater than 0.0 (which is fully
transparent) and the parent item does not clip it.
The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with pos are returned.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
This function was introduced in Qt 4.6.
See also itemAt() and Sorting.
QList\<QGraphicsItem *> QGraphicsScene::items(const QRectF \&rect, Qt::ItemSelectionMode mode \= Qt::IntersectsItemShape, Qt::SortOrder order \= Qt::DescendingOrder, const QTransform \&deviceTransform \= QTransform()) const
This is an overloaded function.
Returns all visible items that, depending on mode, are either inside or intersect with
the specified rect, in a list sorted using order. In this case, "visible" defines
items for which: isVisible() returns true, effectiveOpacity() returns a value greater
than 0.0 (which is fully transparent) and the parent item does not clip it.
The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by rect are returned.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
This function was introduced in Qt 4.6.
See also itemAt() and Sorting.
QList\<QGraphicsItem *> QGraphicsScene::items(const QPolygonF \&polygon, Qt::ItemSelectionMode mode \= Qt::IntersectsItemShape, Qt::SortOrder order \= Qt::DescendingOrder, const QTransform \&deviceTransform \= QTransform()) const
This is an overloaded function.
Returns all visible items that, depending on mode, are either inside or intersect with
the specified polygon, in a list sorted using order. In this case, "visible" defines
items for which: isVisible() returns true, effectiveOpacity() returns a value greater
than 0.0 (which is fully transparent) and the parent item does not clip it.
The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by polygon are returned.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
This function was introduced in Qt 4.6.
See also itemAt() and Sorting.
QList\<QGraphicsItem *> QGraphicsScene::items(const QPainterPath \&path, Qt::ItemSelectionMode mode \= Qt::IntersectsItemShape, Qt::SortOrder order \= Qt::DescendingOrder, const QTransform \&deviceTransform \= QTransform()) const
This is an overloaded function.
Returns all visible items that, depending on mode, are either inside or intersect with
the specified path, in a list sorted using order. In this case, "visible" defines
items for which: isVisible() returns true, effectiveOpacity() returns a value greater
than 0.0 (which is fully transparent) and the parent item does not clip it.
The default value for mode is Qt::IntersectsItemShape; all items whose exact shape intersects with or is contained by path are returned.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
This function was introduced in Qt 4.6.
See also itemAt() and Sorting.
QList\<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform \&deviceTransform \= QTransform()) const
This is an overloaded function.
Returns all visible items that, depending on mode, are either inside or intersect with
the rectangle defined by x, y, w and h, in a list sorted using order. In this
case, "visible" defines items for which: isVisible() returns true, effectiveOpacity()
returns a value greater than 0.0 (which is fully transparent) and the parent item does
not clip it.
deviceTransform is the transformation that applies to the view, and needs to be provided if the scene contains items that ignore transformations.
This function was introduced in Qt 4.6.
Upstream PySide2 reference signatures (binding differences may apply):
items(self, order: PySide2.QtCore.Qt.SortOrder=...) -> typing.List[PySide2.QtWidgets.QGraphicsItem]
items(self, path: PySide2.QtGui.QPainterPath, mode: PySide2.QtCore.Qt.ItemSelectionMode=..., order: PySide2.QtCore.Qt.SortOrder=..., deviceTransform: PySide2.QtGui.QTransform=...) -> typing.List[PySide2.QtWidgets.QGraphicsItem]
items(self, polygon: PySide2.QtGui.QPolygonF, mode: PySide2.QtCore.Qt.ItemSelectionMode=..., order: PySide2.QtCore.Qt.SortOrder=..., deviceTransform: PySide2.QtGui.QTransform=...) -> typing.List[PySide2.QtWidgets.QGraphicsItem]
items(self, pos: PySide2.QtCore.QPointF, mode: PySide2.QtCore.Qt.ItemSelectionMode=..., order: PySide2.QtCore.Qt.SortOrder=..., deviceTransform: PySide2.QtGui.QTransform=...) -> typing.List[PySide2.QtWidgets.QGraphicsItem]
items(self, rect: PySide2.QtCore.QRectF, mode: PySide2.QtCore.Qt.ItemSelectionMode=..., order: PySide2.QtCore.Qt.SortOrder=..., deviceTransform: PySide2.QtGui.QTransform=...) -> typing.List[PySide2.QtWidgets.QGraphicsItem]
items(self, x: float, y: float, w: float, h: float, mode: PySide2.QtCore.Qt.ItemSelectionMode, order: PySide2.QtCore.Qt.SortOrder, deviceTransform: PySide2.QtGui.QTransform=...) -> typing.List[PySide2.QtWidgets.QGraphicsItem]
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#items
itemsBoundingRect
itemsBoundingRect() -> Any
X.itemsBoundingRect() -> PythonQt.QtCore.QRectF
Supplemental documentation: Qt 5 reference:
QRectF QGraphicsScene::itemsBoundingRect() const
Calculates and returns the bounding rect of all items on the scene. This function works by iterating over all items, and because of this, it can be slow for large scenes.
See also sceneRect().
Upstream PySide2 reference signatures (binding differences may apply):
itemsBoundingRect(self) -> PySide2.QtCore.QRectF
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#itemsBoundingRect
keyPressEvent
keyPressEvent(event: Any) -> None
X.keyPressEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsScene::keyPressEvent(QKeyEvent *keyEvent)
This event handler, for event keyEvent, can be reimplemented in a subclass to receive keypress events. The default implementation forwards the event to current focus item.
See also QGraphicsItem::keyPressEvent() and focusItem().
Upstream PySide2 reference signatures (binding differences may apply):
keyPressEvent(self, event: PySide2.QtGui.QKeyEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#keyPressEvent
keyReleaseEvent
keyReleaseEvent(event: Any) -> None
X.keyReleaseEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsScene::keyReleaseEvent(QKeyEvent *keyEvent)
This event handler, for event keyEvent, can be reimplemented in a subclass to receive key release events. The default implementation forwards the event to current focus item.
See also QGraphicsItem::keyReleaseEvent() and focusItem().
Upstream PySide2 reference signatures (binding differences may apply):
keyReleaseEvent(self, event: PySide2.QtGui.QKeyEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#keyReleaseEvent
minimumRenderSize
instance-attribute
minimumRenderSize: float
Qt 5 reference:
minimumRenderSize : qreal
This property holds the minimal view-transformed size an item must have to be drawn
When the scene is rendered, any item whose width or height, transformed to the target view, is smaller that minimumRenderSize(), will not be rendered. If an item is not rendered and it clips its children items they will also not be rendered. Set this value to speed up rendering of scenes with many objects rendered on a zoomed out view.
The default value is 0. If unset, or if set to 0 or a negative value, all items will always be rendered.
For example, setting this property can be especially useful if a scene is rendered by multiple views, one of which serves as an overview which always displays all items. In scenes with many items, such a view will use a high scaling factor so that all items can be shown. Due to the scaling, smaller items will only make an insignificant contribution to the final rendered scene. To avoid drawing these items and reduce the time necessary to render the scene, you can call setMinimumRenderSize() with a non-negative value.
Note: Items that are not drawn as a result of being too small, are still returned by methods such as items() and itemAt(), and participate in collision detection and interactions. It is recommended that you set minimumRenderSize() to a value less than or equal to 1 in order to avoid large unrendered items that are interactive.
This property was introduced in Qt 5.4.
Access functions:
| qreal | minimumRenderSize() const |
|---|---|
| void | setMinimumRenderSize(qreal minSize) |
See also QStyleOptionGraphicsItem::levelOfDetailFromTransform().
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#minimumRenderSize
mouseDoubleClickEvent
mouseDoubleClickEvent(event: Any) -> None
X.mouseDoubleClickEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent)
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse double-click events for the scene.
If someone doubleclicks on the scene, the scene will first receive a mouse press event, followed by a release event (i.e., a click), then a double-click event, and finally a release event. If the double-click event is delivered to a different item than the one that received the first press and release, it will be delivered as a press event. However, tripleclick events are not delivered as double-click events in this case.
The default implementation is similar to mousePressEvent().
Note: See items() for a definition of which items are considered visible by this function.
See also QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseMoveEvent(), QGraphicsItem::mouseReleaseEvent(), and QGraphicsItem::setAcceptedMouseButtons().
Upstream PySide2 reference signatures (binding differences may apply):
mouseDoubleClickEvent(self, event: PySide2.QtWidgets.QGraphicsSceneMouseEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#mouseDoubleClickEvent
mouseGrabberItem
mouseGrabberItem() -> Any
X.mouseGrabberItem() -> PythonQt.QtGui.QGraphicsItem
Supplemental documentation: Qt 5 reference:
QGraphicsItem *QGraphicsScene::mouseGrabberItem() const
Returns the current mouse grabber item, or nullptr if no item is currently grabbing
the mouse. The mouse grabber item is the item that receives all mouse events sent to the
scene.
An item becomes a mouse grabber when it receives and accepts a mouse press event, and it stays the mouse grabber until either of the following events occur:
- If the item receives a mouse release event when there are no other buttons pressed, it loses the mouse grab.
- If the item becomes invisible (i.e., someone calls
item->setVisible(false)), or if it becomes disabled (i.e., someone callsitem->setEnabled(false)), it loses the mouse grab. - If the item is removed from the scene, it loses the mouse grab.
If the item loses its mouse grab, the scene will ignore all mouse events until a new item grabs the mouse (i.e., until a new item receives a mouse press event).
Upstream PySide2 reference signatures (binding differences may apply):
mouseGrabberItem(self) -> PySide2.QtWidgets.QGraphicsItem
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#mouseGrabberItem
mouseMoveEvent
mouseMoveEvent(event: Any) -> None
X.mouseMoveEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse move events for the scene.
The default implementation depends on the mouse grabber state. If there is a mouse grabber item, the event is sent to the mouse grabber. If there are any items that accept hover events at the current position, the event is translated into a hover event and accepted; otherwise it's ignored.
See also QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseReleaseEvent(), QGraphicsItem::mouseDoubleClickEvent(), and QGraphicsItem::setAcceptedMouseButtons().
Upstream PySide2 reference signatures (binding differences may apply):
mouseMoveEvent(self, event: PySide2.QtWidgets.QGraphicsSceneMouseEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#mouseMoveEvent
mousePressEvent
mousePressEvent(event: Any) -> None
X.mousePressEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse press events for the scene.
The default implementation depends on the state of the scene. If there is a mouse grabber item, then the event is sent to the mouse grabber. Otherwise, it is forwarded to the topmost visible item that accepts mouse events at the scene position from the event, and that item promptly becomes the mouse grabber item.
If there is no item at the given position on the scene, the selection area is reset, any focus item loses its input focus, and the event is then ignored.
Note: See items() for a definition of which items are considered visible by this function.
See also QGraphicsItem::mousePressEvent() and QGraphicsItem::setAcceptedMouseButtons().
Upstream PySide2 reference signatures (binding differences may apply):
mousePressEvent(self, event: PySide2.QtWidgets.QGraphicsSceneMouseEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#mousePressEvent
mouseReleaseEvent
mouseReleaseEvent(event: Any) -> None
X.mouseReleaseEvent(event)
Supplemental documentation: Qt 5 reference:
[virtual protected] void QGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
This event handler, for event mouseEvent, can be reimplemented in a subclass to receive mouse release events for the scene.
The default implementation depends on the mouse grabber state. If there is no mouse grabber, the event is ignored. Otherwise, if there is a mouse grabber item, the event is sent to the mouse grabber. If this mouse release represents the last pressed button on the mouse, the mouse grabber item then loses the mouse grab.
See also QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseMoveEvent(), QGraphicsItem::mouseDoubleClickEvent(), and QGraphicsItem::setAcceptedMouseButtons().
Upstream PySide2 reference signatures (binding differences may apply):
mouseReleaseEvent(self, event: PySide2.QtWidgets.QGraphicsSceneMouseEvent) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#mouseReleaseEvent
objectNameChanged
objectNameChanged(*args: Any, **kwargs: Any) -> Any
Native PythonQt.QtGui.QGraphicsScene.objectNameChanged; argument details are not documented.
palette
instance-attribute
palette: QPalette
Qt 5 reference:
palette : QPalette
This property holds the scene's default palette
This property provides the scene's palette. The scene palette defaults to, and resolves all its entries from, QApplication::palette.
If the scene's palette changes, either directly through setPalette() or indirectly when the application palette changes, QGraphicsScene first sends itself a PaletteChange event, and it then sends PaletteChange events to all top-level widget items in the scene. These items respond by resolving their own palettes to the scene, and they then notify their children, who again notify their children, and so on, until all widget items have updated their palettes.
Changing the scene palette, (directly or indirectly through QApplication::setPalette(),) automatically schedules a redraw the entire scene.
This property was introduced in Qt 4.4.
Access functions:
| QPalette | palette() const |
|---|---|
| void | setPalette(const QPalette \&palette) |
See also QWidget::palette, QApplication::setPalette(), font, and style().
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#palette
removeItem
removeItem(item: Any) -> None
X.removeItem(item)
Supplemental documentation: Qt 5 reference:
void QGraphicsScene::removeItem(QGraphicsItem *item)
Removes the item item and all its children from the scene. The ownership of item is passed on to the caller (i.e., QGraphicsScene will no longer delete item when destroyed).
See also addItem().
Upstream PySide2 reference signatures (binding differences may apply):
removeItem(self, item: PySide2.QtWidgets.QGraphicsItem) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#removeItem
render
render(painter: Any, target: Any, source: Any, aspectRatioMode: Any) -> None
X.render(painter, target, source, aspectRatioMode)
Supplemental documentation: Qt 5 reference:
void QGraphicsScene::render(QPainter *painter, const QRectF \&target \= QRectF(), const QRectF \&source \= QRectF(), Qt::AspectRatioMode aspectRatioMode \= Qt::KeepAspectRatio)
Renders the source rect from scene into target, using painter. This function is useful for capturing the contents of the scene onto a paint device, such as a QImage (e.g., to take a screenshot), or for printing with QPrinter. For example:
QGraphicsScene scene;
scene.addItem(...
...
QPrinter printer(QPrinter::HighResolution);
printer.setPaperSize(QPrinter::A4);
QPainter painter(&printer);
scene.render(&painter);
If source is a null rect, this function will use sceneRect() to determine what to render. If target is a null rect, the dimensions of painter's paint device 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.
See also QGraphicsView::render().
Upstream PySide2 reference signatures (binding differences may apply):
render(self, painter: PySide2.QtGui.QPainter, target: PySide2.QtCore.QRectF=..., source: PySide2.QtCore.QRectF=..., aspectRatioMode: PySide2.QtCore.Qt.AspectRatioMode=...) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#render
sceneRect
instance-attribute
sceneRect: QRectF
Qt 5 reference:
sceneRect : QRectF
This property holds the scene rectangle; the bounding rectangle of the scene
The scene rectangle defines the extent of the scene. It is primarily used by QGraphicsView to determine the view's default scrollable area, and by QGraphicsScene to manage item indexing.
If unset, or if set to a null QRectF, sceneRect() will return the largest bounding rect of all items on the scene since the scene was created (i.e., a rectangle that grows when items are added to or moved in the scene, but never shrinks).
Access functions:
| QRectF | sceneRect() const |
|---|---|
| void | setSceneRect(const QRectF \&rect) |
| void | setSceneRect(qreal x, qreal y, qreal w, qreal h) |
See also width(), height(), and QGraphicsView::sceneRect.
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#sceneRect
sceneRectChanged
sceneRectChanged(*args: Any, **kwargs: Any) -> Any
Native PythonQt.QtGui.QGraphicsScene.sceneRectChanged; argument details are not documented.
Supplemental documentation: Qt 5 reference:
[signal] void QGraphicsScene::sceneRectChanged(const QRectF \&rect)
This signal is emitted by QGraphicsScene whenever the scene rect changes. The rect parameter is the new scene rectangle.
See also QGraphicsView::updateSceneRect().
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#sceneRectChanged
selectedItems
selectedItems() -> tuple
X.selectedItems() -> tuple
Supplemental documentation: Qt 5 reference:
QList\<QGraphicsItem *> QGraphicsScene::selectedItems() const
Returns a list of all currently selected items. The items are returned in no particular order.
See also setSelectionArea().
Upstream PySide2 reference signatures (binding differences may apply):
selectedItems(self) -> typing.List[PySide2.QtWidgets.QGraphicsItem]
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#selectedItems
selectionArea
selectionArea() -> Any
X.selectionArea() -> PythonQt.QtGui.QPainterPath
Supplemental documentation: Qt 5 reference:
QPainterPath QGraphicsScene::selectionArea() const
Returns the selection area that was previously set with setSelectionArea(), or an empty QPainterPath if no selection area has been set.
See also setSelectionArea().
Upstream PySide2 reference signatures (binding differences may apply):
selectionArea(self) -> PySide2.QtGui.QPainterPath
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#selectionArea
selectionChanged
selectionChanged(*args: Any, **kwargs: Any) -> Any
Native PythonQt.QtGui.QGraphicsScene.selectionChanged; argument details are not documented.
Supplemental documentation: Qt 5 reference:
[signal] void QGraphicsScene::selectionChanged()
This signal is emitted by QGraphicsScene whenever the selection changes. You can call selectedItems() to get the new list of selected items.
The selection changes whenever an item is selected or unselected, a selection area is set, cleared or otherwise changed, if a preselected item is added to the scene, or if a selected item is removed from the scene.
QGraphicsScene emits this signal only once for group selection operations. For example, if you set a selection area, select or unselect a QGraphicsItemGroup, or if you add or remove from the scene a parent item that contains several selected items, selectionChanged() is emitted only once after the operation has completed (instead of once for each item).
This function was introduced in Qt 4.3.
See also setSelectionArea(), selectedItems(), and QGraphicsItem::setSelected().
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#selectionChanged
sendEvent
sendEvent(item: Any, event: Any) -> bool
X.sendEvent(item, event) -> bool
Supplemental documentation: Qt 5 reference:
bool QGraphicsScene::sendEvent(QGraphicsItem *item, QEvent *event)
Sends event event to item item through possible event filters.
The event is sent only if the item is enabled.
Returns false if the event was filtered or if the item is disabled. Otherwise returns
the value that was returned from the event handler.
This function was introduced in Qt 4.6.
See also QGraphicsItem::sceneEvent() and QGraphicsItem::sceneEventFilter().
Upstream PySide2 reference signatures (binding differences may apply):
sendEvent(self, item: PySide2.QtWidgets.QGraphicsItem, event: PySide2.QtCore.QEvent) -> bool
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#sendEvent
setActivePanel
setActivePanel(item: Any) -> None
X.setActivePanel(item)
Supplemental documentation: Qt 5 reference:
void QGraphicsScene::setActivePanel(QGraphicsItem *item)
Activates item, which must be an item in this scene. You can also pass 0 for item, in which case QGraphicsScene will deactivate any currently active panel.
If the scene is currently inactive, item remains inactive until the scene becomes
active (or, ir item is nullptr, no item will be activated).
This function was introduced in Qt 4.6.
See also activePanel(), isActive(), and QGraphicsItem::isActive().
Upstream PySide2 reference signatures (binding differences may apply):
setActivePanel(self, item: PySide2.QtWidgets.QGraphicsItem) -> None
Source: https://doc.qt.io/archives/qt-5.15/qgraphicsscene.html#setActivePanel