PySide6.QtWidgets.QGraphicsRectItem¶
- class QGraphicsRectItem¶
The
QGraphicsRectItemclass provides a rectangle item that you can add to aQGraphicsScene.Details
To set the item’s rectangle, pass a QRectF to
QGraphicsRectItem‘s constructor, or call thesetRect()function. Therect()function returns the current rectangle.
QGraphicsRectItemuses the rectangle and the pen width to provide a reasonable implementation ofboundingRect(),shape(), andcontains(). Thepaint()function draws the rectangle using the item’s associated pen and brush, which you can set by calling thesetPen()andsetBrush()functions.Note
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 QRectF::normalized() to create normalized rectangles, and use those instead.
Synopsis¶
Methods¶
def
__init__()def
rect()def
setRect()
Note
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
- __init__([parent=None])¶
- Parameters:
parent –
QGraphicsItem
Constructs a
QGraphicsRectItem.parentis passed toQAbstractGraphicsShapeItem‘s constructor.See also
- __init__(rect[, parent=None])
- Parameters:
rect –
QRectFparent –
QGraphicsItem
Constructs a
QGraphicsRectItem, usingrectas the default rectangle.parentis passed toQAbstractGraphicsShapeItem‘s constructor.See also
- __init__(x, y, w, h[, parent=None])
- Parameters:
x – float
y – float
w – float
h – float
parent –
QGraphicsItem
Constructs a
QGraphicsRectItemwith a default rectangle defined by (x,y) and the givenwidthandheight.parentis passed toQAbstractGraphicsShapeItem‘s constructor.See also
Returns the item’s rectangle.
See also
Sets the item’s rectangle to be the given
rectangle.See also
- setRect(x, y, w, h)
- Parameters:
x – float
y – float
w – float
h – float