QAbstractGraphicsShapeItem's perimeter to QPainterPath
-
In my application, i am using many shapes which are directly or indirectly inherited the following classes
QGraphicsEllipseItem
QGraphicsPolygonItem
QGraphicsRectItemNow i need to return its perimeter as shape() . How to compute any shape which inherited QAbstractGraphicsShapeItem.
-
In my application, i am using many shapes which are directly or indirectly inherited the following classes
QGraphicsEllipseItem
QGraphicsPolygonItem
QGraphicsRectItemNow i need to return its perimeter as shape() . How to compute any shape which inherited QAbstractGraphicsShapeItem.
@repl
Not that I am an expert here, but QPainterPath QGraphicsEllipseItem::shape() const
etc. overrideshape()
and returnQGraphicsEllipseItem uses the rect and the pen width to provide a reasonable implementation of boundingRect(), shape(), and contains().
and
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:
so isn't that all you are supposed to use?
-
@JonB : boundingRect() returns complete area. But here i am looking for only perimeter.
FOr exmaple: I draw a star shapeThe QPen in painter draws the black outline & QBrush fills yellow color. Not my question is , Ho would i save the block outline [blck coloured outline ] as my painterpath ?