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. Why does QGraphicsView::update( const QRegion& ) cause the whole widget to be updated?

Why does QGraphicsView::update( const QRegion& ) cause the whole widget to be updated?

Scheduled Pinned Locked Moved Unsolved General and Desktop
painteventqgraphicssceneupdateqgraphicsview
2 Posts 1 Posters 1.6k Views
  • 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.
  • N Offline
    N Offline
    Nick C
    wrote on 14 Jan 2016, 11:57 last edited by Nick C
    #1

    I have a large, complicated graphics view that takes a lot of processing to draw, and so I only want to redraw part of it (an OpenGL video display) each frame, leaving the rest (various child widgets etc) unchanged.

    However, when I call update() with a QRegion, the paintEvent's region is the full size of the widget, so the whole screen gets redrawn every time. There doesn't appear to be any call to update() with no parameters (at least, not my version thereof)

    What might be causing the paint event to have the full screen in it?

    void GLGraphicsView::updateVideoRegion(const QRegion & r)
    {
        //this function called from outside...
        LOG4CXX_DEBUG(_logger, "updateVideoRegion " << r.boundingRect().x() << " " << r.boundingRect().y() << " " << r.boundingRect().width() << " " << r.boundingRect().height());
        update(r);  
    }
    
    void GLGraphicsView::update()
    {
        LOG4CXX_DEBUG(_logger, "update(all)");
        QGraphicsView::update();
    }
    
    void GLGraphicsView::update(const QRegion& region)
    {
        LOG4CXX_DEBUG(_logger, "update(region) " << region.boundingRect().x() << " " << region.boundingRect().y() << " " << region.boundingRect().width() << " " << region.boundingRect().height());
        QGraphicsView::update(region);
    }
    
    void GLGraphicsView::paintEvent(QPaintEvent *e)
    {
        LOG4CXX_DEBUG(_logger, "repaint region " << e->region().boundingRect().x() << " " << e->region().boundingRect().y() << " " << e->region().boundingRect().width() << " " << e->region().boundingRect().height());
    
        /* Do the rest of the painting */
    }
    

    Output:

    updateVideoRegion 19 19 1446 568
    update(region) 19 19 1446 568
    repaint region 0 0 1920 1201
    

    <edit>
    I've also tried using updateScene(QList<QRectF>) instead of update(QRegion), with viewportUpdateMode set to SmartViewportUpdate, but the paintEvent's region is still the full size of the screen

    Can I make it only re-draw the region that has changed? If not, why not?

    1 Reply Last reply
    0
    • N Offline
      N Offline
      Nick C
      wrote on 15 Jan 2016, 14:12 last edited by
      #2

      After further investigation, it appears that this is because I am using OpenGL - the 'fullUpdate' flag in updateScene is always set in this case - qgraphicsView has "accelerateScrolling = !isGlWidget" [in setupViewport, line 2759] and "fullUpdate = !d->accelerateScrolling" [in updateScene, line 2675]

      1 Reply Last reply
      0

      2/2

      15 Jan 2016, 14:12

      • Login

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