Ed Nio
Ed Nio

Reputation: 593

How to disable ScrollView

I use a ScrollView for my ListView but I need sometimes to disable it.

A simple case would be something like that :

ScrollView {
    id: scroll
    ListView {
        model: DelegateModel {
            id: visualModel
            model: myModel //Model is set in the cpp
            delegate: Rectangle {
                    ...
                Button {
                    onClicked { //Important part
                        scroll.flickableItem.interactive = false //It doesn't work 
                    }
                }
            }
        }
    }
}   

How could I proceed ?

Upvotes: 0

Views: 818

Answers (1)

derM
derM

Reputation: 13691

As dtech mentioned, the ListView has a built-in Flickable so to scroll, no ScrollView is needed for that. You can also add ScrollBars to a ListView by using:

ScrollBar.vertical: ScrollBar {}

However if you need to use the ScrollView as you want the old-school look-and-feel there is no documented way. Actually, when using QtQuick.Controls 1.x you have to resort to undocumented properties of the Controls quite often.

In this particular case, you could set the properties:

__horizontalScrollBar.enabled: false
__verticalScrollBar.enabled: false
__wheelAreaScrollSpeed: 0

Again: this is not documented and might change if there would be a newer version of the QtQuick.Controls 1.x - this however is unlikely, as right now the focus lies on the development of the modern QtQuick.Controls 2.x which are incompatible with the documented API of the 1.x-versions

Upvotes: 1

Related Questions