Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QRectF QGraphicsItem::boundingRect (  )  const [pure virtual]

This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be restricted to inside an item's bounding rect. QGraphicsView uses this to determine whether the item requires redrawing.

Although the item's shape can be arbitrary, the bounding rect is always rectangular, and it is unaffected by the items' transformation (scale(), rotate(), etc.).

If you want to change the item's bounding rectangle, you must first call prepareGeometryChange(). This notifies the scene of the imminent change, so that its can update its item geometry index; otherwise, the scene will be unaware of the item's new geometry, and the results are undefined (typically, rendering artifacts are left around in the view).

Reimplement this function to let QGraphicsView determine what parts of the widget, if any, need to be redrawn.

Note: For shapes that paint an outline / stroke, it is important to include half the pen width in the bounding rect. It is not necessary to compensate for antialiasing, though.


doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 8

See also:
boundingRegion(), shape(), contains(), {The Graphics View Coordinate System}, prepareGeometryChange()

Implemented in SimpleItem, Mouse, Arrow, Node, QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem, QGraphicsLineItem, QGraphicsPixmapItem, QGraphicsTextItem, QGraphicsSimpleTextItem, QGraphicsItemGroup, QGraphicsWidget, and QGraphicsSvgItem.

Referenced by QGraphicsItemGroup::addToGroup(), boundingRegion(), childrenBoundingRect(), collidesWithPath(), isObscured(), isObscuredBy(), QGraphicsScene::items(), QGraphicsScene::itemUpdated(), QGraphicsView::paintEvent(), qt_graphicsItem_highlightSelected(), qt_graphicsItem_highlightSelected(), QGraphicsView::render(), QGraphicsScene::render(), sceneBoundingRect(), scroll(), setCacheMode(), shape(), and update().

Generated by  Doxygen 1.6.0   Back to index