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

Scroll bar not responding to clicks



  • I'm working on a Qt Quick Controls 2 app, and have a ScrollView with a custom ScrollBar that isn't responding to clicks. It works as expected using gestures, but for some reason click and dragging the scroll them doesn't work. The problem happens under 5.10 and 5.11

    Here's a demo app that demonstrates the problem:

    import QtQuick 2.11
    import QtQuick.Window 2.11
    import QtQuick.Layouts 1.3
    import QtQuick.Controls 2.4
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        ScrollView{
            id: settingsScrollView
            contentHeight: 1200
            anchors.top:parent.top
            anchors.bottom:parent.bottom
            anchors.left:parent.left
            width:320
    
    
            ScrollBar.vertical: ScrollBar{
                anchors.top: parent.top
                anchors.right: parent.right
                //anchors.rightMargin: 10   //uncommenting this will allow scroll thumb to be controlled by click and drag
                anchors.bottom: parent.bottom
                width: 10
                contentItem: Rectangle{
                    color: "black"
                }
            }
    
            Column{
                //anchors.fill:parent
                width:320
                height:childrenRect.height
                Rectangle { color: "red"; width: parent.width; height: 300 }
                Rectangle { color: "green"; width: parent.width; height: 300 }
                Rectangle { color: "blue"; width: parent.width; height: 300 }
            }
    
        }
    }
    
    

    Any ideas what is happening here? Is there a work-round?



  • @Bernd-B Thanks for the work-around!

    This definitely looks like a bug in ScrollView....



  • Use Flickable and clip: true

    Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    Flickable {  //change 
         clip: true // change
        id: settingsScrollView
        contentHeight: 1200
        anchors.top:parent.top
        anchors.bottom:parent.bottom
        anchors.left:parent.left
        width:320
    
    
        ScrollBar.vertical: ScrollBar{
            anchors.top: parent.top
            anchors.right: parent.right
            //anchors.rightMargin: 10   //uncommenting this will allow scroll thumb to be controlled by click and drag
            anchors.bottom: parent.bottom
            width: 10
            contentItem: Rectangle{
                color: "black"
            }
        }
    
        Column{
            //anchors.fill:parent
            width:320
            height:childrenRect.height
            Rectangle { color: "red"; width: parent.width; height: 300 }
            Rectangle { color: "green"; width: parent.width; height: 300 }
            Rectangle { color: "blue"; width: parent.width; height: 300 }
        }
    
    }
    

    }



  • @Bernd-B Thanks for the work-around!

    This definitely looks like a bug in ScrollView....


Log in to reply