Results 1 to 4 of 4

Thread: QGraphicsView: overlay widget on top of view to speedup rubber band select/zoom?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Oct 2014
    Posts
    81
    Thanks
    20
    Thanked 9 Times in 9 Posts
    Qt products
    Qt5
    Platforms
    Windows
    Wiki edits
    7

    Default Re: QGraphicsView: overlay widget on top of view to speedup rubber band select/zoom?

    Isn't there a way to crop the rendering to only the affected part (commonly called "dirty" region)?
    Areas of the QGraphicsView that are outside of the rubber band widget shouldn't be repainted at all.

    In the paintEvent of your custom item you can retrieve the 'exposedRect' value from the parameter QStyleOptionGraphicsItem. It supposedly indicates the "dirty" area to be painted, but you need to set the proper item flag for this to happen:
    http://doc.qt.io/qt-5/qstyleoptiongr...xposedRect-var
    http://doc.qt.io/qt-5/qgraphicsitem.html#setFlag

    Qt Code:
    1. void MyGraphicsItem::paint( QPainter *painter,
    2. const QStyleOptionGraphicsItem *option,
    3. {
    4. // Here comes the magic:
    5. painter->setClipRect( option->exposedRect );
    6.  
    7. // All your custom painting code goes here.
    8. // ...
    9. }
    To copy to clipboard, switch view to plain text mode 
    Taken from: http://thesmithfam.org/blog/2007/02/...w-performance/ (Note it's for Qt 4.)
    Last edited by Kryzon; 11th March 2015 at 03:26.

Similar Threads

  1. rubber band zoom on a qwtpolarplot
    By john_k in forum Qwt
    Replies: 1
    Last Post: 2nd August 2014, 10:53
  2. QgraphicsView rubber band selection rectangle not visible
    By tarunrajsingh in forum Qt Programming
    Replies: 1
    Last Post: 3rd April 2013, 16:44
  3. How can I implement rubber-band with graphics view items?
    By FinderCheng in forum Qt Programming
    Replies: 6
    Last Post: 14th February 2013, 12:01
  4. Replies: 1
    Last Post: 28th February 2012, 09:54
  5. Conditional rubber band selection in QGraphicsView
    By stevel in forum Qt Programming
    Replies: 5
    Last Post: 14th January 2011, 08:32

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
  •  
Qt is a trademark of The Qt Company.