Results 1 to 4 of 4

Thread: Redraw only selected items in QgraphicsScene.

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

    Default Redraw only selected items in QgraphicsScene.

    hi all,
    I am using a QGraphicsView to display 10,000+ items, and i have figured out how to use QGraphicsItem:aint() to draw or not draw the items. But for performance reason, i want to redraw only any selected items, data of which is updated, instead of redrawing all of items completely. Is there anyway to achieve it?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Redraw only selected items in QgraphicsScene.

    Graphics view automatically only redraws those items which have been modified. You can tweak the exact behaviour using update modes and item caching.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    loading... (21st January 2015)

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

    Default Re: Redraw only selected items in QgraphicsScene.

    Quote Originally Posted by wysota View Post
    Graphics view automatically only redraws those items which have been modified. You can tweak the exact behaviour using update modes and item caching.
    thanks for reply, wysota.
    You're right, i know Qtgui say like you too. But if you have got 2 QgraphicsItems, and their bounding rect is the same, when you call update function to redraw the first item, second item will be redrawn too. I have tested it, and this is my problem.
    Sorry for my bad english.
    Thanks.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Redraw only selected items in QgraphicsScene.

    Enable item caching for your items. Both items will be redrawn however the paint() routine will be called for only that item which really changed. To be honest I don't like what you have written in your initial post, it seems to me you are doing some hacky things to prevent items from painting instead of using facilities the framework offers. You shouldn't have to "figure out how to use paint() to draw or not draw the items".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    loading... (21st January 2015)

Similar Threads

  1. Replies: 1
    Last Post: 7th August 2012, 19:05
  2. QGraphicsScene - clone selected item by Alt+Move
    By qtsoul in forum Qt Programming
    Replies: 2
    Last Post: 4th December 2011, 10:24
  3. QGraphicsScene sorting selected items
    By akiross in forum Qt Programming
    Replies: 1
    Last Post: 2nd April 2011, 19:23
  4. How to redraw QGraphicsScene background in running
    By wisconxing in forum Qt Programming
    Replies: 3
    Last Post: 17th November 2008, 13:10
  5. Getting indexes of selected items
    By gyre in forum Newbie
    Replies: 2
    Last Post: 20th November 2007, 19:23

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.