(QML)滚动多个列表视图

(QML)滚动多个列表视图

可以Listview在 qml 中一起滚动多个 s 吗?

这是我的尝试:

        Flickable {
            id: scoreflick
            anchors.top: namesrow.bottom
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.leftMargin: units.gu(2)
            anchors.topMargin: units.gu(2)

            Row {
                spacing: namesrow.spacing

                ListView {
                            id: p1list
                            width: units.gu(9)
                            height: units.gu(20)
                            model: 30

                            delegate: TextField {
                                width: ListView.view.width
                                height: units.gu(3)
                                text: "Score"
                            }
                        }

                ListView {
                            id: p2list
                            width: units.gu(9)
                            height: units.gu(20)
                            model: 30

                            delegate: TextField {
                                width: ListView.view.width
                                height: units.gu(3)
                                text: "Score"
                            }
                        }

                ListView {
                            id: p3list
                            width: units.gu(9)
                            height: units.gu(20)
                            model: 30

                            delegate: TextField {
                                width: ListView.view.width
                                height: units.gu(3)
                                text: "Score"
                            }
                        }

                ListView {
                            id: p4list
                            width: units.gu(9)
                            height: units.gu(20)
                            model: 30

                            delegate: TextField {
                                width: ListView.view.width
                                height: units.gu(3)
                                text: "Score"
                            }
                        }

            }

        }

        Scrollbar {
            flickableItem: scoreflick
            align: Qt.AlignTrailing
        }

但是每次单独Listview滚动都根本不起作用Scrollbar...有什么帮助吗?

答案1

以下内容对我有帮助。您将需要:

    onContentXChanged: {
        if(activeFocus){
            p2list.contentX = p1list.contentX  
iterate all list
for (var i=0; i<listOfListView.children.length; i++){
    if(listOfListView.children[i].activeFocus) {

    }
}

相关内容