Results 1 to 2 of 2

Thread: Using QPersistentModelIndex

  1. #1
    Join Date
    Dec 2006
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Using QPersistentModelIndex

    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/...tentModelIndex

    Any insights?

    Thanks,

    RobF

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using QPersistentModelIndex

    Quote Originally Posted by Nb2Qt View Post
    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...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.