QGraphicsRectItem露

The QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene . More鈥�

Inheritance diagram of PySide2.QtWidgets.QGraphicsRectItem

Synopsis露

Functions露

Detailed Description露

To set the item鈥檚 rectangle, pass a QRectF to QGraphicsRectItem 鈥榮 constructor, or call the setRect() function. The rect() function returns the current rectangle.

../../_images/graphicsview-rectitem.png

QGraphicsRectItem uses the rectangle and the pen width to provide a reasonable implementation of boundingRect() , shape() , and contains() . The paint() function draws the rectangle using the item鈥檚 associated pen and brush, which you can set by calling the setPen() and setBrush() 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:

PySide2.QtWidgets.QGraphicsItem

param x:

float

param y:

float

param h:

float

param rect:

PySide2.QtCore.QRectF

Constructs a QGraphicsRectItem . parent is passed to QAbstractGraphicsShapeItem 鈥榮 constructor.

See also

addItem()

Constructs a QGraphicsRectItem , using rect as the default rectangle. parent is passed to QAbstractGraphicsShapeItem 鈥榮 constructor.

See also

addItem()

Constructs a QGraphicsRectItem with a default rectangle defined by (x , y ) and the given width and height .

parent is passed to QAbstractGraphicsShapeItem 鈥榮 constructor.

See also

addItem()

PySide2.QtWidgets.QGraphicsRectItem.rect()露
Return type:

PySide2.QtCore.QRectF

Returns the item鈥檚 rectangle.

See also

setRect()

PySide2.QtWidgets.QGraphicsRectItem.setRect(rect)露
Parameters:

rect 鈥� PySide2.QtCore.QRectF

Sets the item鈥檚 rectangle to be the given rectangle .

See also

rect()

PySide2.QtWidgets.QGraphicsRectItem.setRect(x, y, w, h)
Parameters:
  • x 鈥� float

  • y 鈥� float

  • w 鈥� float

  • h 鈥� float