Unsolved How to repaint entire visibleRegion - not only a part - when QScrollBar's value is changed
-
Hi,
I have QScrollArea and big widget on it. In big widget's paintEvent I paint many things. I notice that, when I change QScrollArea's ScrollBar for example like this:
scrollArea->verticalScrollBar()->setValue(scrollArea->verticalScrollBar()->value()+1);
I don't repaint entire widget's visibleRegion, but only a part. I see that in paintEvent() method:
event->region();
I would like to change entire widget's visibleRegion always.
Of course I can do something like that:
scrollArea->verticalScrollBar()->setValue(scrollArea->verticalScrollBar()->value()+1); repaint();
but maybe there is a better idea?
I tried in paintEvent() method something like that:
if(event->region() != visibleRegion()) { event->ignore(); repaint(visibleRegion()); return; }
But I get warning on debuq:
QWidget::repaint: Recursive repaint detected
-
Maybe you can change the clipping with:
void QPainter::setClipRegion(const QRegion ®ion, Qt::ClipOperation operation = Qt::ReplaceClip)BTW what you are trying to do is strange ...
-
@mpergand It not works. Why is it strange? I have many if-s statements in paintEvent(), so I many times paint in different way. I have to repaint whole area, not only new part.
-
I'm pretty sure that your if statements are wrong.
It's up to you to redraw all the elements that intersect with the redraw region.