PDA

View Full Version : Hande a *lot* of pixmaps (Qt4.4)



bunjee
19th May 2008, 20:04
Hey guys I have a list of 10 000 contacts. Each one has its one avatar's picture.

I'm displaying them in a QListView.

How can I avoid keeping everything in memory without sacrificing performances ?

Thanks.

thomir
19th May 2008, 20:39
How can I avoid keeping everything in memory without sacrificing performances ?I would think that the short answer is that you cannot keep all the images out of memory, and still get the best performance. However, I havce a few ideas below:



In a typical use, will the user actually see all 10000 images ont he screen? I.e.- will they scroll down to the bottom of your list widget? If not, then you could try only loading the images on the screen at the time, although that might cause slowdown while scrolling the list widget. To avoid this, perhaps you could load the pixmap data in another thread...
Are all 10,000 images unique? If not, perhaps just load the images once, and store references / pointers to them.
Reduce the memory usage by reducing the size of the pictures.

This may not be useful to you, but one way to generate a large number of unique avatar pictures for inline forums etc. is to have a list of foreground and background pictures. The user can pick one of each, and you then composite the foreground and background pictures. This way, you can define 10 background, and 10 foreground pictures, thereby giving you a total of 100 unique pictures. This also reduces the memory requirements when you need to load them all...


Hope this helps!

patrik08
20th May 2008, 02:25
Hey guys I have a list of 10 000 contacts. Each one has its one avatar's picture.
I'm displaying them in a QListView.
How can I avoid keeping everything in memory without sacrificing performances ?
Thanks.

I fill a sqlite database with 6000 tumbnail and big image 2-6 evry contact
to display each 500 to 500 row tumbnail people wait 1.5 / 2 second... on limit 100 is quick..

MarkoSan
20th May 2008, 11:08
You could use proxy model and load thumbnails on per page basis ...