Results 1 to 4 of 4

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

  1. #1
    Join Date
    Jan 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

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

    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?

    Qt Code:
    1. void GLGraphicsView::updateVideoRegion(const QRegion & r)
    2. {
    3. //this function called from outside...
    4. LOG4CXX_DEBUG(_logger, "updateVideoRegion " << r.boundingRect().x() << " " << r.boundingRect().y() << " " << r.boundingRect().width() << " " << r.boundingRect().height());
    5. update(r);
    6. }
    7.  
    8. void GLGraphicsView::update()
    9. {
    10. LOG4CXX_DEBUG(_logger, "update(all)");
    11. QGraphicsView::update();
    12. }
    13.  
    14. void GLGraphicsView::update(const QRegion& region)
    15. {
    16. LOG4CXX_DEBUG(_logger, "update(region) " << region.boundingRect().x() << " " << region.boundingRect().y() << " " << region.boundingRect().width() << " " << region.boundingRect().height());
    17. QGraphicsView::update(region);
    18. }
    19.  
    20. void GLGraphicsView::paintEvent(QPaintEvent *e)
    21. {
    22. LOG4CXX_DEBUG(_logger, "repaint region " << e->region().boundingRect().x() << " " << e->region().boundingRect().y() << " " << e->region().boundingRect().width() << " " << e->region().boundingRect().height());
    23.  
    24. /* Do the rest of the painting */
    25. }
    To copy to clipboard, switch view to plain text mode 
    Output:
    Qt Code:
    1. updateVideoRegion 19 19 1446 568
    2. update(region) 19 19 1446 568
    3. repaint region 0 0 1920 1201
    To copy to clipboard, switch view to plain text mode 

    I've also tried using updateScene(QList<QRectF>) instead of update(QRegion), but that doesn't seem to cause a paintEvent to be generated?

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

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Why does QGraphicsView::update(const QRegion&) cause the whole widget to be updat

    What are the view's viewportUpdateMode and cacheMode?

  3. #3
    Join Date
    Jan 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Why does QGraphicsView::update(const QRegion&) cause the whole widget to be updat

    Both are set to none (CacheNone and NoViewportUpdate respectively). Setting cache to CacheBackground stops the OpenGL stuff rendering, and changing the viewport update settings doesn't seem to make any difference - the region passed into the paintEvent is always the full screen

  4. #4
    Join Date
    Jan 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Why does QGraphicsView::update(const QRegion&) cause the whole widget to be updat

    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]

Similar Threads

  1. Replies: 4
    Last Post: 7th March 2013, 17:20
  2. Replies: 0
    Last Post: 18th November 2010, 17:48
  3. QGraphicsView not being updated
    By Luc4 in forum Qt Programming
    Replies: 14
    Last Post: 14th August 2010, 16:48
  4. Replies: 5
    Last Post: 17th June 2009, 15:01
  5. QGraphicsView won't update until resize
    By stevel in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2009, 22:45

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.