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

Ole Streicher ole-usenet-spam at gmx.net
Tue Sep 29 16:07:50 CEST 2009


Hi,

I have a huge graphics scene that contains about 100.000 individual
items (Ellipses, squares) whose colors are regularly updated.

My problem is now, that updating the colors takes quite a long time (10
seconds on a quite fast machine). Is there a way to improve the speed or
do I have to live with it? Here the (Python) code that takes so long
(mydata is an array that holds the colors, myitems is the list that holds
the items)
-----------------------------8<---------------------------------
#
# This takes a long time.
# 
for gray, item in zip(mydata, myitems):
    item.brush().color().setRgb(gray, gray, gray)

#
# scene.update() is quite fast compared to the lines above.
#
scene.update()
-----------------------------8<---------------------------------

Aside from having this written in Python (which is testable not the
bottleneck), what is the reason why this is quite slow? It seems that
the setRgb() is the cause here.

Or is QGraphicsScene not designed for so many objects? What else should
one use instead?

Best regards

Ole




More information about the Qt-interest-old mailing list