Important: Please read the Qt Code of Conduct -

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:


    I don't repaint entire widget's visibleRegion, but only a part. I see that in paintEvent() method:


    I would like to change entire widget's visibleRegion always.

    Of course I can do something like that:


    but maybe there is a better idea?

    I tried in paintEvent() method something like that:

        if(event->region() != visibleRegion())

    But I get warning on debuq:

    QWidget::repaint: Recursive repaint detected

  • Maybe you can change the clipping with:
    void QPainter::setClipRegion(const QRegion &region, 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.

Log in to reply