I found out this has to do with me only creating the object once, then adding an arcTo
and a few other lines to it during each run of paint()
. Since I can't flush the QPainterPath the Path simply becomes longer and longer and longer and longer.
This explains why old lines are not being flushed and why the brush is alternating (each time I re-draw the same thing I am forming a new intersection with the path itself, wich by design is not being filled).
I fixed it like this:
void DrawArc::paint(QPainter* painter)
{
painter->save();
//...
QPainterPath path = QPainterPath(*this);
path.arcTo(/*...*/);
path.lineTo(/*...*/);
painter->translate(QPoint(100,100));
painter->drawPath(path);
painter->restore();
}
So in each drawing operation I create a copy of the current path, add all lines I need to it and paint that one. After exiting paint
, that drawn path is being discarded.