Show sublevel of model in ListView



  • 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?



  • 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.



  • I think what you are after is KBreadcrumbSelectionModel



  • @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.



  • @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


Log in to reply
 

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