PDA

View Full Version : Caching icons in QListView::IconMode



slash_blog
30th August 2011, 10:08
I am using QListView in IconMode to display items. The problem is, any kind of operation, even clicking for context menu or scrolling of items makes application non-responsive. The problem (seems) to be that every time I scroll, the view gets screen-full of data from the model (including Pixmaps for all the Icons). This IMO is the culprit that is slowing down the application. So I have decided to maintain an icon cache in the view.

Now, to the best of my understanding (please correct me if I am wrong), I need to subclass the delegate so that view does not query for icon image each time there is need for it to be drawn. But the only way I have control over item drawing is to override the paint () function from QItemDelegate class. Is there a better way to do it, because this way I would have to implement all that the paint () function does in the base class, because I can not really use base class function as it works on QModelIndex.

Can somebody help me on this?

wysota
31st August 2011, 08:03
It depends what your delegate is supposed to do. It might be easier if you focus on optimizing the model instead.

slash_blog
1st September 2011, 14:13
Actually I could optimize model to acceptable level. So the problem is under control now.

Thanks for your response though!