Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to access 3 dimensional array from C++ to QML
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 256 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    flowery
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved