Horizontal ScrollBar for Vertical ListView .



  • I have ListView , listView width is lessthan its ContentWidth & height is less than ContentHeight .
    I added Two scrollbar (Vertical and Horizontal).
    Vertical Scrollbar is working fine. Horizontalscrollbar Content Item is taking the entire width of the list which is preventing the scroll behavour.

    I replaced the list view with Flickable , having width is lessthan its ContentWidth & height is less than ContentHeight .
    Both Horizontal and Vertical scrollbar is working fine.

    Listview inherits Flickable so horizontal scrollbar should work with List view also but, it is not.

    My sample application is below.

    ApplicationWindow {
    visible: true
    width: 640
    height: 480

    Rectangle {
        width: 400;
        height: 300;
    
        ListView {
            id: list;
            width: parent.width
            height: parent.height
            contentWidth:  parent.width * 4
            model: 20;
            clip : true
            delegate: Rectangle {
                height: 50;
                width: parent.width;
                color: (model.index %2 === 0 ? "darkgray" : "lightgray");
            }
            ScrollBar.horizontal: ScrollBar{
                contentItem: Rectangle {
                    implicitWidth: 6
                    implicitHeight: 100
                    radius: width / 2
                    color: "black"
                }}
            ScrollBar.vertical: ScrollBar{contentItem: Rectangle {
                    implicitWidth: 6
                    implicitHeight: 100
                    radius: width / 2
                    color: "black"
                }}
    
        }
    
    }
    

    }


Log in to reply
 

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