Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QGraphicsRectItem Class

TheQGraphicsRectItem class provides a rectangle item that you can add to aQGraphicsScene.More...

Header:#include <QGraphicsRectItem>
Since: Qt 4.2
Inherits:QAbstractGraphicsShapeItem

Public Functions

QGraphicsRectItem(QGraphicsItem * parent = 0)
QGraphicsRectItem(const QRectF & rect, QGraphicsItem * parent = 0)
QGraphicsRectItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem * parent = 0)
~QGraphicsRectItem()
QRectFrect() const
voidsetRect(const QRectF & rectangle)
voidsetRect(qreal x, qreal y, qreal width, qreal height)

Reimplemented Public Functions

virtual QRectFboundingRect() const
virtual boolcontains(const QPointF & point) const
virtual boolisObscuredBy(const QGraphicsItem * item) const
virtual QPainterPathopaqueArea() const
virtual voidpaint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0)
virtual QPainterPathshape() const
virtual inttype() const

Additional Inherited Members

Detailed Description

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.

Member Function Documentation

QGraphicsRectItem::QGraphicsRectItem(QGraphicsItem * parent = 0)

Constructs aQGraphicsRectItem.parent is passed toQAbstractGraphicsShapeItem's constructor.

See alsoQGraphicsScene::addItem().

QGraphicsRectItem::QGraphicsRectItem(constQRectF & rect,QGraphicsItem * parent = 0)

Constructs aQGraphicsRectItem, usingrect as the default rectangle.parent is passed toQAbstractGraphicsShapeItem's constructor.

See alsoQGraphicsScene::addItem().

QGraphicsRectItem::QGraphicsRectItem(qreal x,qreal y,qreal width,qreal height,QGraphicsItem * parent = 0)

Constructs aQGraphicsRectItem with a default rectangle defined by (x,y) and the givenwidth andheight.

parent is passed toQAbstractGraphicsShapeItem's constructor.

See alsoQGraphicsScene::addItem().

QGraphicsRectItem::~QGraphicsRectItem()

Destroys theQGraphicsRectItem.

[virtual]QRectF QGraphicsRectItem::boundingRect() const

Reimplemented fromQGraphicsItem::boundingRect().

[virtual]bool QGraphicsRectItem::contains(constQPointF & point) const

Reimplemented fromQGraphicsItem::contains().

[virtual]bool QGraphicsRectItem::isObscuredBy(constQGraphicsItem * item) const

Reimplemented fromQGraphicsItem::isObscuredBy().

[virtual]QPainterPath QGraphicsRectItem::opaqueArea() const

Reimplemented fromQGraphicsItem::opaqueArea().

[virtual]void QGraphicsRectItem::paint(QPainter * painter, constQStyleOptionGraphicsItem * option,QWidget * widget = 0)

Reimplemented fromQGraphicsItem::paint().

QRectF QGraphicsRectItem::rect() const

Returns the item's rectangle.

See alsosetRect().

void QGraphicsRectItem::setRect(constQRectF & rectangle)

Sets the item's rectangle to be the givenrectangle.

See alsorect().

void QGraphicsRectItem::setRect(qreal x,qreal y,qreal width,qreal height)

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

Reimplemented fromQGraphicsItem::shape().

[virtual]int QGraphicsRectItem::type() const

Reimplemented 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.


[8]ページ先頭

©2009-2025 Movatter.jp