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 new (only these rectangles), I want to clip the paint area to these parts. The isNew() function is true, if the rectangle has got a new color since the last time painting.
void Environment::paintEvent(QPaintEvent *event)
{
QPainter painter (this);
Tile t;
//paint the matrix
for(int i=0; i<size; ++
t = matrix[i+j*yizeY];
if(t.isNew()){
painter.setClipRegion(QRegion(t.getRect()));
painter.setBrush(t.getColor());
painter.drawRect(t.getRect());
t.used();
}
}
}
What am I doing wrong? My program is running even slower, when I use the setClipRegion(…) function.
↧








