PDA

View Full Version : Using QPersistentModelIndex



Nb2Qt
4th July 2007, 01:11
I've always hesitated to use QPersistentModelIndex when deriving my own model classes. I don't really know why. Maybe it's the lack of examples that use them or the skimpy "Detailed Description" section in the documentation. But I guess it's mostly that I felt they could/would cause a lot of overhead maintaining them. My guess is that they would have little overhead unless items are being added/removed/moved. Is this true?

Would I see a performance hit using persistent indices instead of rolling my own lookup functionality? I have ~5 model classes possibly containing thousands of indices each most of which are displaying real-time data. These models are then used as inputs into various QSortFilterProxyModels.

The following article discusses the 3 ways of handling the custom data mapping but it doesn't go into any detail regarding QPersistentModelIndex.

http://trolltech.com/developer/faqs/faq_search?SearchableText=QPersistentModelIndex

Any insights?

Thanks,

RobF

wysota
4th July 2007, 08:35
Is this true?
Yes, that's correct.


Would I see a performance hit using persistent indices instead of rolling my own lookup functionality? I have ~5 model classes possibly containing thousands of indices each most of which are displaying real-time data. These models are then used as inputs into various QSortFilterProxyModels.

Each subsequent persistent index slows down every change to the model. So I suggest avoiding having to keep more than a few persistent indices. Instead connect to rowsAboutToBe...() or similar signals and trace the changes yourself, if you really need that.

It really depends on what you need...