The QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene . 更多...
| 頭: | #include <QGraphicsRectItem> |
| qmake: | QT += widgets |
| Since: | Qt 4.2 |
| 繼承: | QAbstractGraphicsShapeItem |
| QGraphicsRectItem (QGraphicsItem * parent = Q_NULLPTR) | |
| QGraphicsRectItem (const QRectF & rect , QGraphicsItem * parent = Q_NULLPTR) | |
| QGraphicsRectItem (qreal x , qreal y , qreal width , qreal height , QGraphicsItem * parent = Q_NULLPTR) | |
| ~QGraphicsRectItem () | |
| QRectF | rect () const |
| void | setRect (const QRectF & rectangle ) |
| void | setRect (qreal x , qreal y , qreal width , qreal height ) |
| virtual QRectF | boundingRect () const |
| virtual bool | contains (const QPointF & point ) const |
| virtual bool | isObscuredBy (const QGraphicsItem * item ) const |
| virtual QPainterPath | opaqueArea () const |
| virtual void | paint (QPainter * painter , const QStyleOptionGraphicsItem * option , QWidget * widget = Q_NULLPTR) |
| virtual QPainterPath | shape () const |
| virtual int | type () const |
The QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene .
要設置項的矩形,傳遞 QRectF to QGraphicsRectItem 's constructor, or call the setRect () 函數。 rect () 函數返迴當前矩形。
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.
另請參閱 QGraphicsPathItem , QGraphicsEllipseItem , QGraphicsPolygonItem , QGraphicsTextItem , QGraphicsLineItem , QGraphicsPixmapItem ,和 圖形視圖框架 .
構造 QGraphicsRectItem . parent 被傳遞給 QAbstractGraphicsShapeItem 的構造函數。
另請參閱 QGraphicsScene::addItem ().
構造 QGraphicsRectItem ,使用 rect 作為默認矩形。 parent 被傳遞給 QAbstractGraphicsShapeItem 的構造函數。
另請參閱 QGraphicsScene::addItem ().
構造 QGraphicsRectItem with a default rectangle defined by ( x , y ) 和給定 width and height .
parent 被傳遞給 QAbstractGraphicsShapeItem 的構造函數。
另請參閱 QGraphicsScene::addItem ().
銷毀 QGraphicsRectItem .
[虛擬]
QRectF
QGraphicsRectItem::
boundingRect
() const
重實現自 QGraphicsItem::boundingRect ().
[虛擬]
bool
QGraphicsRectItem::
contains
(const
QPointF
&
point
) const
重實現自 QGraphicsItem::contains ().
[虛擬]
bool
QGraphicsRectItem::
isObscuredBy
(const
QGraphicsItem
*
item
) const
重實現自 QGraphicsItem::isObscuredBy ().
[虛擬]
QPainterPath
QGraphicsRectItem::
opaqueArea
() const
重實現自 QGraphicsItem::opaqueArea ().
[虛擬]
void
QGraphicsRectItem::
paint
(
QPainter
*
painter
, const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
= Q_NULLPTR)
重實現自 QGraphicsItem::paint ().
返迴項的矩形。
另請參閱 setRect ().
將項的矩形設為給定 rectangle .
另請參閱 rect ().
將項的矩形設為矩形,定義通過 ( x , y ) 和給定 width and height .
此方便函數相當於調用
setRect(QRectF(x, y, width, height))
另請參閱 rect ().
[虛擬]
QPainterPath
QGraphicsRectItem::
shape
() const
重實現自 QGraphicsItem::shape ().
[虛擬]
int
QGraphicsRectItem::
type
() const
重實現自 QGraphicsItem::type ().