Your code doesn't work for many reasons:
a) You can paint to a widget outside of a paint event only on platforms, where Qt::WA_PaintOutsidePaintEvent is supported ( X11 ).
b) Curve points ( boundingRect() of a curve ) have a different coordinate system than QPainter. You need the canvas maps to translate between them.
c) You have to paint to the canvas - not to the plot widget.
d) You try to erase the complete curve and repaint only parts of it.
e) You try to paint behind the back of the canvas paint cache
...
Guess your intention is to speed up a "realtime" plot by painting only parts of a curve. This works when you are painting additional points, but as soon as you need to erase something you need the XOR mode.
I recommend to initialize your plot like in the data_plot example ( no paint cache ) and find a reasonable refresh rate (limiting replots by a QTimer) for your application.
Uwe
Bookmarks