Scroll two or more ListViews Using Single ScrollBar
Solved
QML and Qt Quick
-
wrote on 29 Aug 2017, 14:06 last edited by pra7
Hello, I need to scroll two or more list view at once using a single scrollBar. Initially, i used
Column
inside aFlickable
but scroll was not happening as expected. Later, I usedListView
and even that was not scrolling correctly.So,how to scroll a listview/layout content item with a scroll bar? Should I use
ScrollView
orFlickable
or something else? -
wrote on 4 Sept 2017, 07:35 last edited by jpnurmi 9 Apr 2017, 07:35
With Qt Quick Controls 2:
import QtQuick 2.9 import QtQuick.Controls 2.2 ApplicationWindow { id: window width: 640 height: 480 visible: true Row { anchors.fill: parent anchors.margins: vbar.width ListView { width: parent.width / 2 height: parent.height model: 100 delegate: ItemDelegate { width: parent.width text: "A" + modelData } ScrollBar.vertical: vbar } ListView { width: parent.width / 2 height: parent.height model: 100 delegate: ItemDelegate { width: parent.width text: "B" + modelData } ScrollBar.vertical: vbar } } ScrollBar { id: vbar height: parent.height anchors.right: parent.right policy: ScrollBar.AlwaysOn } }
-
With Qt Quick Controls 2:
import QtQuick 2.9 import QtQuick.Controls 2.2 ApplicationWindow { id: window width: 640 height: 480 visible: true Row { anchors.fill: parent anchors.margins: vbar.width ListView { width: parent.width / 2 height: parent.height model: 100 delegate: ItemDelegate { width: parent.width text: "A" + modelData } ScrollBar.vertical: vbar } ListView { width: parent.width / 2 height: parent.height model: 100 delegate: ItemDelegate { width: parent.width text: "B" + modelData } ScrollBar.vertical: vbar } } ScrollBar { id: vbar height: parent.height anchors.right: parent.right policy: ScrollBar.AlwaysOn } }
wrote on 12 Sept 2017, 15:29 last edited byThis post is deleted! -
With Qt Quick Controls 2:
import QtQuick 2.9 import QtQuick.Controls 2.2 ApplicationWindow { id: window width: 640 height: 480 visible: true Row { anchors.fill: parent anchors.margins: vbar.width ListView { width: parent.width / 2 height: parent.height model: 100 delegate: ItemDelegate { width: parent.width text: "A" + modelData } ScrollBar.vertical: vbar } ListView { width: parent.width / 2 height: parent.height model: 100 delegate: ItemDelegate { width: parent.width text: "B" + modelData } ScrollBar.vertical: vbar } } ScrollBar { id: vbar height: parent.height anchors.right: parent.right policy: ScrollBar.AlwaysOn } }