QGraphicsRectItem¶
The
QGraphicsRectItem
class provides a rectangle item that you can add to aQGraphicsScene
. More…
Synopsis¶
Functions¶
Detailed Description¶
To set the item’s rectangle, pass a
QRectF
toQGraphicsRectItem
‘s constructor, or call thesetRect()
function. Therect()
function returns the current rectangle.
QGraphicsRectItem
uses 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
normalized()
to create normalized rectangles, and use those instead.
- class PySide2.QtWidgets.QGraphicsRectItem([parent=None])¶
PySide2.QtWidgets.QGraphicsRectItem(rect[, parent=None])
PySide2.QtWidgets.QGraphicsRectItem(x, y, w, h[, parent=None])
- param w:
float
- param parent:
- param x:
float
- param y:
float
- param h:
float
- param rect:
Constructs a
QGraphicsRectItem
.parent
is passed toQAbstractGraphicsShapeItem
‘s constructor.See also
Constructs a
QGraphicsRectItem
, usingrect
as the default rectangle.parent
is passed toQAbstractGraphicsShapeItem
‘s constructor.See also
Constructs a
QGraphicsRectItem
with a default rectangle defined by (x
,y
) and the givenwidth
andheight
.parent
is passed toQAbstractGraphicsShapeItem
‘s constructor.See also
- PySide2.QtWidgets.QGraphicsRectItem.rect()¶
- Return type:
Returns the item’s rectangle.
See also
- PySide2.QtWidgets.QGraphicsRectItem.setRect(rect)¶
- Parameters:
rect –
PySide2.QtCore.QRectF
Sets the item’s rectangle to be the given
rectangle
.See also
- PySide2.QtWidgets.QGraphicsRectItem.setRect(x, y, w, h)
- Parameters:
x – float
y – float
w – float
h – float
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.