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. Hide/show ListView sections dynamically
Qt 6.11 is out! See what's new in the release blog

Hide/show ListView sections dynamically

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 845 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.
  • A Offline
    A Offline
    Adso4
    wrote on last edited by
    #1

    Hi,

    I have a ListView that has a ListView as delegate.
    The Items of the child ListView are elements of a given category. Then, the items of the parent listView are the different categories.
    The model for the children lists are a custom of QSortFilterProxyModel. Then, I would like that if, for filtering options, a child list does not have elements to show, hide the category title. Now, with current behavior, category header is shown with no children.
    Code is:

    ListView {
    			id: headers
    			anchors.fill: parent
    			clip: true
    			boundsBehavior: Flickable.StopAtBounds
    
    			model: _headersModel
    
    			delegate: 
    				Item {
    					width: parent.width
    					height: some_value
    
    					ListView {
    						id: items_of_same_category
    						anchors.fill: parent
    						spacing: 5
    						clip: true
    						interactive: false
    
    						model: proxy_model
    
    						delegate: component_delegate
    					}
    				}
    
    			section.property: "category_value"
                            section.criteria: ViewSection.FullString
                            section.delegate: header_delegate
                            section.labelPositioning: ViewSection.InlineLabels | ViewSection.CurrentLabelAtStart            
    		}
    

    In case of "proxy_model" is retrieving 0 children, header should not be visible.

    1 Reply Last reply
    0
    • oria66O Offline
      oria66O Offline
      oria66
      wrote on last edited by
      #2

      Hey @Adso4. You can use this excellent library that saves a lot of work.

      https://github.com/oKcerG/SortFilterProxyModel

      Good luck.

      The truth is out there

      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