内容表

上一话题

QGraphicsProxyWidget

下一话题

QGraphicsRotation

QGraphicsRectItem

QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene . 更多

Inheritance diagram of PySide2.QtWidgets.QGraphicsRectItem

概要

函数

详细描述

To set the item’s rectangle, pass a QRectF to QGraphicsRectItem ‘s 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() ,和 contains() paint() function draws the rectangle using the item’s associated pen and brush, which you can set by calling the setPen() and setBrush() 函数。

注意

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 QGraphicsRectItem ( [ parent=None ] )

QGraphicsRectItem(rect[, parent=None])

QGraphicsRectItem(x, y, w, h[, parent=None])

param w

qreal

param parent

QGraphicsItem

param x

qreal

param y

qreal

param h

qreal

param rect

QRectF

构造 QGraphicsRectItem . parent 会被传递给 QAbstractGraphicsShapeItem ‘s constructor.

另请参阅

addItem()

构造 QGraphicsRectItem ,使用 rect as the default rectangle. parent 会被传递给 QAbstractGraphicsShapeItem ‘s constructor.

另请参阅

addItem()

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

parent 会被传递给 QAbstractGraphicsShapeItem ‘s constructor.

另请参阅

addItem()

PySide2.QtWidgets.QGraphicsRectItem. rect ( )
返回类型

QRectF

Returns the item’s rectangle.

另请参阅

setRect()

PySide2.QtWidgets.QGraphicsRectItem. setRect ( rect )
参数

rect QRectF

Sets the item’s rectangle to be the given rectangle .

另请参阅

rect()

PySide2.QtWidgets.QGraphicsRectItem. setRect ( x , y , w , h )
参数
  • x qreal

  • y qreal

  • w qreal

  • h qreal