PDA

View Full Version : Redraw only selected items in QgraphicsScene.



loading...
14th January 2015, 14:20
hi all,
I am using a QGraphicsView to display 10,000+ items, and i have figured out how to use QGraphicsItem::paint() 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?

wysota
14th January 2015, 15:39
Graphics view automatically only redraws those items which have been modified. You can tweak the exact behaviour using update modes and item caching.

loading...
17th January 2015, 08:55
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.

wysota
17th January 2015, 09:23
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".