views:

240

answers:

2

I'm using a QPainter to get some graphics on a window. Unfortunately every time the .paintEvent is run, the whole window is cleared. How can I draw without clearing? I.e. how do I leave the stuff from previous paint event untouched?

I'm using Qt4

+1  A: 

In Qt3, set the Qt::WNoAutoErase flag from the WidgetFlags enum to avoid that the window is cleared on each paint event.

You can set this flag by passing it to the QWidget constructor.

Frerich Raabe
Qt Documentation says it no longer needed. So he should not use it
Patrice Bernassola
@Patrice: Ah, yes - in Qt4 it does not work anymore. This is a Qt3 solution.
Frerich Raabe
+3  A: 

You need to set the backgroundMode by using the setBackgroundMode setter. The Qt::NoBackground enum is what you are searching for.

Patrice Bernassola