Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Show sublevel of model in ListView
Qt 6.11 is out! See what's new in the release blog

Show sublevel of model in ListView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 3 Posters 1.6k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    MrQnTi
    wrote on last edited by
    #1

    I've a QAbstractItemModel derived class which contains my model data,
    would like to show it in such way that a user can tap on an item and is presented with its childs.

    basically a touch menu structure (like there are plenty on android etc),
    the user taps on a parent item, the view is cleared and the (previously not shown) childs of that parent are rendered.

    how to archieve that? as the listview cannot show a tree like structure right?
    Or a treeview where you have a backbutton and only see one level at a time is fine too, would that be possible?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      karlheinzreichel
      wrote on last edited by
      #2

      I would use a listview as you plan to show only one level at a time. (so no treeview is necessary).
      You could use a QAbstractItemModel (recursive one, see link text) together with an QSortFilterProxyModel so filter only the items for the selected level.

      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        I think what you are after is KBreadcrumbSelectionModel

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        M 1 Reply Last reply
        1
        • VRoninV VRonin

          I think what you are after is KBreadcrumbSelectionModel

          M Offline
          M Offline
          MrQnTi
          wrote on last edited by
          #4

          @VRonin Indeed something alike, any idea why this is not part of the standard itself?
          anyway i ended up implementing a c++ model which is state-aware (shows only the items of the current level)
          @karlheinzreichel QSortFilterProxyModel could have worked but since my model is a tree it would be a pain to iterate over it all the time
          I'm trying to build something alike the settings menu on an iPhone using Qt Quick,
          and its an horrible amount more complicated than I expected it to be.

          VRoninV 1 Reply Last reply
          0
          • M MrQnTi

            @VRonin Indeed something alike, any idea why this is not part of the standard itself?
            anyway i ended up implementing a c++ model which is state-aware (shows only the items of the current level)
            @karlheinzreichel QSortFilterProxyModel could have worked but since my model is a tree it would be a pain to iterate over it all the time
            I'm trying to build something alike the settings menu on an iPhone using Qt Quick,
            and its an horrible amount more complicated than I expected it to be.

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            @MrQnTi said in Show sublevel of model in ListView:

            Indeed something alike, any idea why this is not part of the standard itself?

            Well, it comes from KDE developers and it's a level 1 library so if you consider Qt "standard" then I don't see why you should not consider KDE Level 1 API at the same level

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            1

            • Login

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