Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Painting the mouse trace with QGraphicsItem
xtraction last edited by
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.
Jake007 last edited by
Did you take a look at the Finger Paint example?
You only replace QTouchEvent with QMouseEvent.