How to H/V scrollable table with A LOT of items (ListView of ListViews)



  • Hi,

    I'm trying to design a qml item that will contain thousands of items with the layout of a grid.

    I tried several approaches (TableView, GridView) but everytime I had issues trying to resize my Component using a rows * columns format or with memory.

    The best approach i found so far is the following:

    import QtQuick 2.4
    import QtQuick.Controls 1.3
    import QtQuick.Window 2.2
    import QtQuick.Dialogs 1.2
    
    ApplicationWindow {
        title: qsTr("Hello World")
        width: 800
        height: 600
        visible: true
    
        Item {
            id: grid
            property int numRows: 1000
            property int numColumns: 1000
            property int cellSize: 35
            property int cellSpacing: 1
    
            anchors.fill: parent
    
            ScrollView {
                id: scrollView
                anchors.fill: parent
                anchors.centerIn: parent
                contentItem: columnsList
    
                ListView {
                    id: columnsList
    
                    anchors.fill: parent
                    anchors.centerIn: parent
                    orientation: ListView.Vertical
                    spacing: grid.cellSpacing
                    clip: true
                    interactive: false
                    cacheBuffer: 1
    
                    model: grid.numRows
    
                    delegate: ListView {
                        id: row
                        width: columnsList.width
                        height: grid.cellSize
                        orientation: ListView.Horizontal
                        spacing: grid.cellSpacing
                        clip: true
                        interactive: false
                        cacheBuffer: 1
    
                        model: grid.numColumns
                        delegate: Rectangle {
                            width: grid.cellSize
                            height: grid.cellSize
                            color: "green"
                        }
                    }
                }
            }
        }
    

    It would be perfect if it wasn't for the fact that the horizontal scrollbar isn't shown!
    I trid also to set height and width manually, but this causes all the cells to be created and it's not acceptable.

    Is it a good approach?
    Is there a workaround to make the horizontal scrollbar appear?



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.