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

ListView (Flickable) with Button Delegates



  • What is the proper way to allow a flick action to work when the ListView is populated with Button delegates? I desire both the onClick() of the button to work and a start of a flick to work if is starts on the button area. In my case I have to start the flick in the background area vs. on the button.

    Thanks,
    -Rich

     ListView {
            id: settingsView
            anchors{left: parent.left; leftMargin: 20; top: headerSeparator.bottom;  bottom: footerSeparator.top; bottomMargin: 10; right: parent.right; rightMargin: 60}
            spacing: 20
            clip: true
            delegate: PushButton {    // Derived from Button with MouseArea
                width: parent.width-70
                height: 70
                buttonText: name
                textAvailable: true
                imageAvailable: false
    
                onClicked: {
                    if(pageName!=="") {
                        pageLoaderSource.pushItem("qrc:/Pages/" + pageName)
                    }
                }
            }
    
            ScrollBar.vertical: ScrollBar {
                policy: settingsModel.count> 4 ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
                width: 14
                clip: true
                contentItem: Rectangle {
                    implicitWidth: 14
                    radius: width / 2; color: "#2EA2EC"
                }
                background: Item {
                    Rectangle {
                        id: handle
                        anchors { fill: parent; margins: 2 }
                        radius: width / 2; color: "#DBDDDD"
                    }
                }
            }
        }
    
    


  • Think I found my answer. My PushButton component had preventStealing: true....deleted this line and behavior seems more as expected.


Log in to reply