Painting the mouse trace with QGraphicsItem



  • Hello,

    I have a QGraphicsView with a scene that displays an image. What I am trying to do now is when I click the mouse and move without un-clicking, I want to draw the mouse trace until the mouse button is released. So basically to draw with the mouse.

    Could someone please guide me to what I need to do for this?

    So far what I am trying to do is subclassing QGraphicsRectItem and from the mouse events of the QGV call my own functions in the GraphicsItem subclass passing as a parameter the QMouseEvent and handling things there.

    I know I have to implement the paint event to draw, but I'm a bit lost how to approach this. I was thinking maybe getting the points of the trace and drawing small line segments in between, would this be a good possible way?

    I appreciate any help. Thanks.



  • Did you take a look at the Finger Paint example?
    You only replace QTouchEvent with QMouseEvent.

    Regards,
    Jake


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.