tags:

views:

552

answers:

1

i want to develop an application to draw a line and rectangle as one can draw in ms paint... keeping one point fixed . can anyone help with any example...

+1  A: 

You'll find a lot of convenience functions in QPainter, such as drawRect.

Use QWidget::mousePressEvent, QWidget::mouseMoveEvent and QWidget::mouseReleaseEvent to know where the user is drawing the shape.

You should have a QImage for the shapes that have already been drawn. While the user is creating a new shape, you'll need to add that to the QPixmap that is shown to the user, but don't add the new shape to the QImage until the user releases the mouse button. That way you can adjust the shape that they're drawing as they draw it.

Bill