Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Best method for a "recursive QListView"?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tory Gaurnier
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #2

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

      Asking a question about code? http://eel.is/iso-c++/testcase/

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tory Gaurnier
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Tory Gaurnier
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved