• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QGraphicsEllipseItem

    下一话题

    QGraphicsPathItem

    QGraphicsRectItem

    概要

    函数

    详细描述

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

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

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

    PySide.QtGui.QGraphicsRectItem uses the rectangle and the pen width to provide a reasonable implementation of PySide.QtGui.QGraphicsRectItem.boundingRect() , PySide.QtGui.QGraphicsRectItem.shape() ,和 PySide.QtGui.QGraphicsRectItem.contains() PySide.QtGui.QGraphicsRectItem.paint() function draws the rectangle using the item's associated pen and brush, which you can set by calling the PySide.QtGui.QAbstractGraphicsShapeItem.setPen() and PySide.QtGui.QAbstractGraphicsShapeItem.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.

    class PySide.QtGui. QGraphicsRectItem ( [ parent=None [ , scene=None ] ] )
    class PySide.QtGui. QGraphicsRectItem ( rect [ , parent=None [ , scene=None ] ] )
    class PySide.QtGui. QGraphicsRectItem ( x , y , w , h [ , parent=None [ , scene=None ] ] )
    参数:
    PySide.QtGui.QGraphicsRectItem. rect ( )
    返回类型: PySide.QtCore.QRectF

    Returns the item's rectangle.

    PySide.QtGui.QGraphicsRectItem. setRect ( rect )
    参数: rect PySide.QtCore.QRectF

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

    PySide.QtGui.QGraphicsRectItem. setRect ( x , y , w , h )
    参数:
    • x PySide.QtCore.qreal
    • y PySide.QtCore.qreal
    • w PySide.QtCore.qreal
    • h PySide.QtCore.qreal

    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))