PDA

View Full Version : free hand draw in qgraphicsview



wagmare
22nd November 2013, 06:02
I have gone through the scribble example for how to draw free form . i want the same free form draw using QGraphicsitem on qgraphicsview. i should draw it as a graphicsitem as i can move the selected free form every where in the scene. i tried this


DrawnPathItem = this->scene()->addPath(QPainterPath());
void view::drawLineTo(const QPointF &startPoint, const QPointF &endPoint)
QGraphicsLineItem liner;
liner.setLine( QLineF(startPoint, endPoint) );
liner.setPen(QPen(Qt::red));

QPainterPath path = DrawnPathItem->path();
path.setFillRule(Qt::WindingFill);
path.addPath( liner.shape() );
path = path.simplified();

DrawnPathItem->setPath(path);
i dont know how to draw as a item on scene .. please help me