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

QPainterPath Node::shape (  )  const [virtual]

Returns the shape of this item as a QPainterPath in local coordinates. The shape is used for many things, including collision detection, hit tests, and for the QGraphicsScene::items() functions.

The default implementation calls boundingRect() to return a simple rectangular shape, but subclasses can reimplement this function to return a more accurate shape for non-rectangular items. For example, a round item may choose to return an elliptic shape for better collision detection. For example:

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

The outline of a shape can vary depending on the width and style of the pen used when drawing. If you want to include this outline in the item's shape, you can create a shape from the stroke using QPainterPathStroker.

This function is called by the default implementations of contains() and collidesWithPath().

See also:
boundingRect(), contains(), prepareGeometryChange(), QPainterPathStroker

Reimplemented from QGraphicsItem.

Definition at line 134 of file node.cpp.

References QPainterPath::addEllipse().

{
    QPainterPath path;
    path.addEllipse(-10, -10, 20, 20);
    return path;
}


Generated by  Doxygen 1.6.0   Back to index