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

How to access 3 dimensional array from C++ to QML



  • Window {
    visible: true
    property var items :[[["blue", "green","yellow"],["red","black"]], [["black","grey"],["white","pink"]]]
    property var subItems:[]
    MouseArea {
    anchors.fill: parent
    onClicked: {
    Qt.quit();
    }
    }

    Row{
        spacing:2
        Repeater{
            id: mainArr
            model: items
    
            Item{
                width: 200
                 height: 150
    
                Column{
                    spacing : 2
                  //  anchors.horizontalCenter: parent.horizontalCenter
                    height: parent.height
                    Repeater{
                        model:items[index]
                        Rectangle{
                            width: 200
                            height: 50
                            color: "blue"
    
                        Row{
                            anchors.horizontalCenter: parent.horizontalCenter
                            //width: 50 ; height: 50; //color: modelData
                            Text{ text: modelData[0]}
                            Text{ text: modelData[1]}
                            Text{ text: modelData[2]}
                        }
                        }
                    }
                }
            }
        }
    }
    

    This is the sample Qml program , whereas I want to read this items array from QT C++.I tried with QList<QList<QVariant>>> datatype ,stored the values and returned in data() function as QVariant::fromValue(items).But I am not getting the values in qml instead just printing the datatype.


Log in to reply