I have a problem with clipping in Qt. I have a widget in which I paint a big array of rectangles. As I only change a few rectangles from time-to-time, I want to paint only a little part of the widget (only these rectangles) and clip the paint area to these parts.
isNew() function is true if the rectangle receives new color since the previous painting.
void Environment::paintEvent(QPaintEvent *event)
QPainter painter (this);
//paint the matrix
for(int i=0; i<size; ++
t = matrix[i+j*yizeY];
What am I doing wrong? My program is running even slower when I use the
If you want to improve performance, you can paint all those rectangles on a QPixmap. As you can draw to the pixmap anytime, you can draw the tiles directly to the pixmap when they needs an update. On the paint event you just draw the "already-rendered" pixmap.
That way you don't have to remember which tiles changed, and you can avoid looping through the whole matrix.