Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make ScrollView clip only vertically?

ScrollView clips all its contents to its size. Is it possible to make it work only for top and bottom but allow children to go out of parent's frame on the right and on the left?

like image 781
Rinat Veliakhmedov Avatar asked Oct 21 '25 10:10

Rinat Veliakhmedov


1 Answers

If what you want is to only scroll in one direction, then just set the width/height of the content item to the width/height of the ScrollView, using property bindings (because items inside ScrollView are reparented to ScrollView.contentItem). The below example will scroll only vertically. I've tested it, if you need confirmation that it actually works.

Item {
    ScrollView {
        id: scrollview1
        anchors.fill: parent
        anchors.margins: 20
        clip: true

        ColumnLayout {
            width: scrollview1.width
        }
    }
}
like image 98
Paul-Sebastian Manole Avatar answered Oct 23 '25 07:10

Paul-Sebastian Manole