QGraphicsRectItem Class Reference

[ QtGui module]

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

继承 QAbstractGraphicsShapeItem .

方法


详细描述

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

要设置项的矩形,传递 QRectF to QGraphicsRectItem's constructor, or call the setRect () function. The rect () function returns the current rectangle.

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 () 和 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 QRectF.normalized () to create normalized rectangles, and use those instead.


方法文档编制

QGraphicsRectItem.__init__ ( self , QGraphicsItem   parent  = None, QGraphicsScene   scene  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

scene argument, if not None, causes self to be owned by Qt instead of PyQt.

构造 QGraphicsRectItem . parent is passed to QAbstractGraphicsShapeItem 's 构造函数。

另请参阅 QGraphicsScene.addItem ().

QGraphicsRectItem.__init__ ( self , QRectF   rect , QGraphicsItem   parent  = None, QGraphicsScene   scene  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

scene argument, if not None, causes self to be owned by Qt instead of PyQt.

构造 QGraphicsRectItem ,使用 rect as the default rectangle. parent 会被传递给 QAbstractGraphicsShapeItem 's 构造函数。

另请参阅 QGraphicsScene.addItem ().

QGraphicsRectItem.__init__ ( self , float  x , float  y , float  w , float  h , QGraphicsItem   parent  = None, QGraphicsScene   scene  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

scene argument, if not None, causes self to be owned by Qt instead of PyQt.

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

parent 会被传递给 QAbstractGraphicsShapeItem 's 构造函数。

另请参阅 QGraphicsScene.addItem ().

QRectF QGraphicsRectItem.boundingRect ( self )

重实现自 QGraphicsItem.boundingRect ().

bool QGraphicsRectItem.contains ( self , QPointF   point )

重实现自 QGraphicsItem.contains ().

bool QGraphicsRectItem.isObscuredBy ( self , QGraphicsItem   item )

重实现自 QGraphicsItem.isObscuredBy ().

QPainterPath QGraphicsRectItem.opaqueArea ( self )

重实现自 QGraphicsItem.opaqueArea ().

QGraphicsRectItem.paint ( self , QPainter   painter , QStyleOptionGraphicsItem   option , QWidget   widget  = None)

重实现自 QGraphicsItem.paint ().

QRectF QGraphicsRectItem.rect ( self )

Returns the item's rectangle.

另请参阅 setRect ().

QGraphicsRectItem.setRect ( self , QRectF   rect )

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

另请参阅 rect ().

QGraphicsRectItem.setRect ( self , float  ax , float  ay , float  w , float  h )

Sets the item's rectangle to the rectangle defined by ( x , y ) and the given width and height .

This convenience function is equivalent to calling setRect(QRectF(x, y, width, height))

另请参阅 rect ().

QPainterPath QGraphicsRectItem.shape ( self )

重实现自 QGraphicsItem.shape ().

int QGraphicsRectItem.type ( self )

重实现自 QGraphicsItem.type ().