Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to repaint entire visibleRegion - not only a part - when QScrollBar's value is changed
Qt 6.11 is out! See what's new in the release blog

How to repaint entire visibleRegion - not only a part - when QScrollBar's value is changed

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 539 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qwe3
    wrote on last edited by
    #1

    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
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on last edited by
      #2

      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 ...

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qwe3
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mpergand
          wrote on last edited by mpergand
          #4

          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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved