Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED] Unable to scroll on ListView within Column



  • I cannot scroll the pageif I start scrolling within the Listview, however if I start scrolling on the text, it works fine.

    Item {
      anchors {
        top: parent.top
        left: parent.left
        right: parent.right
      }
      implicitHeight: selectItemsColumn.implicitHeight
    
      Column {
        id: selectItemsColumn
        anchors {
          top: parent.top
          left: parent.left
          right: parent.right
        }
        spacing: 50
    
        Text {
           id: title
           anchors {
              left: parent.left
              right: parent.right
           }
           text: "Title"
         }
    
         Item {
           id: itemsHolder
           anchors {
              left: parent.left
              right: parent.right
           }
           implicitHeight: selectList.contentHeight
    
           ListView {
              id: selectList
              anchors.fill: parent
              //model: testModel
              boundsBehavior: Flickable.StopAtBounds
              delegate: Item {}
           }
         }
      }
    

    PS: This qml file is being push into StackView

    Any advise? Thanks.



  • Hi literA2,
    I am not sure I have well understood your issue, I think a comprehensive exemple would helps...but I don't understand why do you ensure every containing items to have an implicit height of its content : doesn't it remove the need of the flickable ?



  • I have modified your exemple to clarify my doubt about the implicit height (the button switch from your design to a height limitation)...is it relevant ?

    import QtQuick 2.2
    import QtQuick.Window 2.1
    import QtQuick.Controls 1.2
    import QtQml 2.2
    
    Window{
        id:page1
        visible:true
    
        width:640
        height:480
    
        property color baseColor : "lightgrey"
        property bool limitHeight : false;
    
        Rectangle {
          color : Qt.darker(itemsHolder.color)
          anchors {
            top: parent.top
            left: parent.left
            right: parent.right
          }
          implicitHeight: page1.limitHeight ? Math.min(300,selectItemsColumn.implicitHeight) : selectItemsColumn.implicitHeight
    
    
          Column {
            id: selectItemsColumn
            anchors {
              top: parent.top
              left: parent.left
              right: parent.right
            }
            spacing: 50
    
            Button{
                anchors.horizontalCenter: parent.horizontalCenter
                text: "change height constraint"
                onClicked: page1.limitHeight = !page1.limitHeight
            }
            Text {
               id: title
               anchors {
                  left: parent.left
                  right: parent.right
               }
               text: "Title"
             }
    
    
             Rectangle {
               id: itemsHolder
               color : Qt.darker(page1.baseColor)
               anchors {
                  left: parent.left
                  right: parent.right
               }
               implicitHeight: page1.limitHeight ? Math.min(250,selectList.contentHeight) : selectList.contentHeight
    
               ListView {
                  id: selectList
                  anchors.fill: parent
                  model: 30//testModel
                  boundsBehavior: Flickable.StopAtBounds
                  delegate: Rectangle{
                      anchors.horizontalCenter: parent.horizontalCenter
                      color:page1.baseColor; width: parent.width *.8;  height: 20
                      Text {
                      anchors.centerIn: parent
                      text:index
                      }
                  }
               }
             }
          }
        }
    }
    
    


  • @Charby Thanks for the reply.

    I actually set an implicitHeight on the main Item so that it will be flickable once pushed into StackView's holder.

    My problem is I cannot flick or scroll if i start scrolling on the listview delegates. However, if i will start scrolling on the title, it will scroll up.



  • Sorry I still don't understand your issue...

    Do you have the same problem with my example ? Is it the same after having clicked on "change height constraint" ?
    Or please send a complete example so I could reproduce the problem.



  • @Charby Thank you for your time replying on this issue.

    After several tries, i managed to resolved the issue by creating ListView as main component and make use of the header for the title.


Log in to reply