Results 1 to 2 of 2

Thread: Handling mass data with QTreeView/QTableView

  1. #1
    Join Date
    Jan 2006
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Handling mass data with QTreeView/QTableView

    Hallo all,

    I am just wondering how to handle big amounts of data with the above mentioned views. I am using Qt 4.1.4. My problem here is:

    I have a big amount of data (e.g. 100000 items) stored in an MySQL database that can only be retrieved via a special interface (usage of QtSQL classes therefore not possible here).
    Retrieving these items is not very fast and so I thought it would be a good idea to implement a kind of cache that handles 50 items (which is the maximum amount of data that can be shown in the view) and reload other items by the underlying model within the index() method into the cache when the appropriate index is called (e.g if index 51 is called, the first item in my cache is thrown away since it is no more visible in the view and the item 51 is loaded from the database). The models rowCount() method is set to 100000 in this example.

    This approach seemed to work so far for a QTableView. My problem now is when I am trying a similar approach with a QTreeView I am running into problems since QTreeView seems to call the models index() method for all items from 0 to rowCount() even if these are not visible.

    So I am wondering if my approach is wrong or if there is something I can do to hinder QTreeView from calling index() for all items even if these are not visible.

    Thanks for any hint
    Greetings
    Kai

    PS: CUrrently playing with QT4.2 rc1. Seems that the QTableView of this version now behaves as the QTreeView in my above example. My problem now becomes more urgent because it seems that my approach is wrong.
    Last edited by alsuffndruff; 1st October 2006 at 23:44.

  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: Handling mass data with QTreeView/QTableView

    It's hard to say. In theory you can limit the rowcount to the real value and use canFetchMore and fetchMore to return additional parts of data, but I'm not sure how it will work in this case.
    Some other idea might be to use some other method than index() to trigger the fetch, for example the data() method. But all this is risky, you should think about a better way to fill the full model (for example fetch items for the model in a separate thread).

Similar Threads

  1. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  2. How to convert binary data to hexadecimal data
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 8th March 2006, 16:17
  3. Replies: 16
    Last Post: 7th March 2006, 15:57

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.