This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
QGraphicsRectItem uses the rectangle and the pen width to provide a reasonable implementation of
shape() , and
contains() . The
paint() function draws the rectangle using the item’s associated pen and brush, which you can set by calling the
The rendering of invalid rectangles, such as those with negative widths or heights, is undefined. If you cannot be sure that you are using valid rectangles (for example, if you are creating rectangles using data from an unreliable source) then you should use
normalized() to create normalized rectangles, and use those instead.
- class PySide6.QtWidgets.QGraphicsRectItem([parent=None])#
PySide6.QtWidgets.QGraphicsRectItem(x, y, w, h[, parent=None])
QGraphicsRectItem with a default rectangle defined by (
y) and the given
parent is passed to
QAbstractGraphicsShapeItem ‘s constructor.
Returns the item’s rectangle.
Sets the item’s rectangle to be the given
- PySide6.QtWidgets.QGraphicsRectItem.setRect(x, y, w, h)
x – float
y – float
w – float
h – float