Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-94848

Missing element in drawer when used with ListView and Section

    XMLWordPrintable

Details

    • 3aad05bc09 (qt/qtdeclarative/dev) 3aad05bc09 (qt/tqtc-qtdeclarative/dev) def37f47b0 (qt/qtdeclarative/6.3) def37f47b0 (qt/tqtc-qtdeclarative/6.3)

    Description

      When a listview with sections is added to a Drawer, first element in listview is not visible. Please refer to the attached sample and the snapshot for the issue.

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Controls 2.15
      
      Window {
          id: root
          width: 640
          height: 480
          visible: true
      
          Button {
              anchors.centerIn: parent
              text: "drawer"
              onClicked: {
                  if (drawer.opened)
                      drawer.close()
                  else
                      drawer.open()
              }
          }
      
          Drawer {
              id: drawer
      
              width: 0.33 * root.width
              height: root.height
              clip: true
              ListView {
                  id: listview
      
                  width: parent.width
                  height: parent.height
      
                  clip: true
      
                  model: ListModel {
                      id: stackviewmodel
      
                      ListElement {
                          title: "page 1"
                          isVisible: true
                          section: "section 1"
                      }
                      ListElement {
                          title: "page 2"
                          isVisible: true
                          section: "section 1"
                      }
                      ListElement {
                          title: "page 3"
                          isVisible: true
                          section: "section 1"
                      }
                      ListElement {
                          title: "page 4"
                          isVisible: true
                          section: "section 1"
                      }
                      ListElement {
                          title: "page 5"
                          isVisible: true
                          section: "section 1"
                      }
      
                      ListElement {
                          title: "page 1"
                          isVisible: false
                          section: "section 2"
                      }
                      ListElement {
                          title: "page 2"
                          isVisible: false
                          section: "section 2"
                      }
      
                      ListElement {
                          title: "page 1"
                          isVisible: false
                          section: "section 3"
                      }
                      ListElement {
                          title: "page 2"
                          isVisible: false
                          section: "section 3"
                      }
      
                      ListElement {
                          title: "page 1"
                          isVisible: false
                          section: "section 4"
                      }
                      ListElement {
                          title: "page 2"
                          isVisible: false
                          section: "section 4"
                      }
                  }
      
                  delegate: ItemDelegate {
                      id: controlitemdelegate
      
                      width: parent.width
                      height: visible ? 48 : 0
                      text: model.title
                      visible: model.isVisible
                      padding: 0
                  }
      
                  section.property: "section"
                  section.criteria: ViewSection.FullString
      
                  section.delegate: Component {
                      Rectangle {
                          id: sectionDelegate
      
                          width: parent.width
                          height: visible ? 48 : 0
      
                          Rectangle {
                              anchors.left: parent.left
                              anchors.right: parent.right
                              anchors.bottom: parent.bottom
                              height: 1
                              color: "green"
                          }
      
                          Text {
                              id: sectionTxt
      
                              text: section
                              width: parent.width
                              font.bold: true
                              anchors.right: parent.right
                              anchors.verticalCenter: parent.verticalCenter
                              verticalAlignment: Text.AlignVCenter
                              elide: Text.ElideMiddle
                          }
      
                          MouseArea {
                              anchors.fill: parent
                              onClicked: {
                                  for (var i = 0; i < stackviewmodel.count; i++) {
                                      var page = stackviewmodel.get(i)
                                      if (page.section === section) {
                                          page.isVisible = !page.isVisible
                                      }
                                  }
                              }
                          }
                      }
                  }
                  ScrollIndicator.vertical: ScrollIndicator {}
              }
          }
      }
      

      Attachments

        1. qtbug94848.zip
          3 kB
        2. qtbug94848.PNG
          qtbug94848.PNG
          61 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              hurlevent Oliver Eftevaag
              shmittal Shveta Mittal (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes