[SOLVED] Best method for a "recursive QListView"?



  • I am working on a library program, think of it like iTunes, and I am going to use a QListView in icon mode to view the contents, first it will display all of the artists, then you click on an artist and it will repopulate the list view with all the albums from that artist, then click an album and it'll repopulate with all the songs in that album. Now the first thing that came to mind is I can create a multidimensional array/list of models, and have a model of every possible combination (a model for all artists, then a model for every artist containing their albums, then a model for every album containing their songs), but my gut tells me this is excessive and will consume a lot of memory. What is the best way to accomplish this? Would it be best to just have a single model and have it completely clear and repopulate the model when navigating?

    I know a tree model is basically what I'm after, however I'm not using a tree view, as I stated I'm using a list view in icon mode, and I'm going to have a "back arrow" above the list view to back out of a category.

    Thanks in advance for any tips/tricks to accomplishing this.



  • That sounds like a reasonable job for a relational database. Does QSqlTableModel look like a candidate?



  • After checking out the SQL models, that seems like it would work pretty well, the only issue is my data is all stored in an XML file, and I'm not sure if I want to switch to a database, would it be possible to load data from an XML file into a QSqlTableModel?



  • OK, so after reading up on stuff for a while I think I know what I need to do, I really do not want to switch to a database file, and then I realized that the QSqlTableModel is just an implementation of QAbstractItemModel, so I think what I need to do is make my own implementation of QAbstractItemModel that can filter and display only what needs to be displayed at a given time.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.