Quote Originally Posted by Rachol View Post
I don't know how do you create the QPainterPath, but it seems like you are not inserting moveTo element to the first point of the path.
Actually, I -was- inserting a moveTo element as the first point in the path, that is why I could not understand where the artifacts were coming from. What I believe was happening was that the last element was not a "closeSubpath", and that was the cause of the spurious lines. After I added that call, the artifacts went away.

So, my lasso rubberband consists of a moveTo call, followed by a series of lineTo calls that track the mouse position. I then use QPainterPath::toFillPolygon() to create a polygon, add this to a new path and append a closeSubpath() to that. I draw this new closed polygon (as a path) in the paint event. Works perfectly.

Using the QPainterPath as a way to track mouse movement lets me implement the rubber band as a horizontal or vertical line, rectangle, ellipse, or lasso (free-form polygon). The start point is captured on mousePressEvent, and the correct path is created (or appended to) in the mouseMoveEvent.

One curious thing: in the mouseMoveEvent, the event->button() is always Qt::NoButton, even though a click-drag is in progress with the left mouse button pressed (at least on Windows).