
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQGraphicsRectItem class provides a rectangle item that you can add to aQGraphicsScene.More...
| Header: | #include <QGraphicsRectItem> |
| Since: | Qt 4.2 |
| Inherits: | QAbstractGraphicsShapeItem |
| QGraphicsRectItem(QGraphicsItem * parent = 0) | |
| QGraphicsRectItem(const QRectF & rect, QGraphicsItem * parent = 0) | |
| QGraphicsRectItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem * parent = 0) | |
| ~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 = 0) |
| virtual QPainterPath | shape() const |
| virtual int | type() const |
TheQGraphicsRectItem class provides a rectangle item that you can add to aQGraphicsScene.
To set the item's rectangle, pass aQRectF toQGraphicsRectItem's constructor, or call thesetRect() function. Therect() function returns the current rectangle.

QGraphicsRectItem uses the rectangle and the pen width to provide a reasonable implementation ofboundingRect(),shape(), andcontains(). Thepaint() function draws the rectangle using the item's associated pen and brush, which you can set by calling thesetPen() andsetBrush() 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 useQRectF::normalized() to create normalized rectangles, and use those instead.
See alsoQGraphicsPathItem,QGraphicsEllipseItem,QGraphicsPolygonItem,QGraphicsTextItem,QGraphicsLineItem,QGraphicsPixmapItem, andGraphics View Framework.
Constructs aQGraphicsRectItem.parent is passed toQAbstractGraphicsShapeItem's constructor.
See alsoQGraphicsScene::addItem().
Constructs aQGraphicsRectItem, usingrect as the default rectangle.parent is passed toQAbstractGraphicsShapeItem's constructor.
See alsoQGraphicsScene::addItem().
Constructs aQGraphicsRectItem with a default rectangle defined by (x,y) and the givenwidth andheight.
parent is passed toQAbstractGraphicsShapeItem's constructor.
See alsoQGraphicsScene::addItem().
Destroys theQGraphicsRectItem.
[virtual]QRectF QGraphicsRectItem::boundingRect() constReimplemented fromQGraphicsItem::boundingRect().
[virtual]bool QGraphicsRectItem::contains(constQPointF & point) constReimplemented fromQGraphicsItem::contains().
[virtual]bool QGraphicsRectItem::isObscuredBy(constQGraphicsItem * item) constReimplemented fromQGraphicsItem::isObscuredBy().
[virtual]QPainterPath QGraphicsRectItem::opaqueArea() constReimplemented fromQGraphicsItem::opaqueArea().
[virtual]void QGraphicsRectItem::paint(QPainter * painter, constQStyleOptionGraphicsItem * option,QWidget * widget = 0)Reimplemented fromQGraphicsItem::paint().
Returns the item's rectangle.
See alsosetRect().
Sets the item's rectangle to be the givenrectangle.
See alsorect().
Sets the item's rectangle to the rectangle defined by (x,y) and the givenwidth andheight.
This convenience function is equivalent to callingsetRect(QRectF(x, y, width, height))
See alsorect().
[virtual]QPainterPath QGraphicsRectItem::shape() constReimplemented fromQGraphicsItem::shape().
[virtual]int QGraphicsRectItem::type() constReimplemented fromQGraphicsItem::type().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.