[Qt-interest] Best way to update 10^5 items

Andre Somers andre at familiesomers.nl
Tue Sep 29 17:08:45 CEST 2009


Oliver.Knoll at comit.ch wrote:
> Ole Streicher wrote on Tuesday, September 29, 2009 4:08 PM:
>
>   
>> Hi,
>>
>> I have a huge graphics scene that contains about 100.000 individual
>> items (Ellipses, squares) whose colors are regularly updated. 
>>     
>
> Typically you don't need to update *all* objects; unless they are about 4x4 pixels in size and fill an entire 1680 x 1024 screen (roughly ;) without overlapping each other.
>
> So your problem is the typical graphic scenario: "Which objects are actually visible on the screen?" Or in other words: "Which objects do I actually have to *really* re-paint?"
>
> The solution off course depends on your data model/organisation (hierarchical trees, such as octrees in 3D scenarios etc.), but in the end it all boils down to "clipping":
>
>   
Assuming you are not managing your items yourself, but let 
QGraphicsScene do that, take a look at this method:
QList<QGraphicsItem *> QGraphicsScene::items ( const QPolygonF & 
polygon, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape ) const

If you call it with the visible polygon (which you can get via the 
QGraphicsView class), have the clipping problem solved. You get a list 
of items that are actually visible.

All the tips form Oliver still apply, of course :-)

André

 



More information about the Qt-interest-old mailing list