QML: how to access to model.modelData N element



  • Hi all,
    I am writing an application in which a c++ plugin exposes a QObjectList as in this example:
    http://doc.qt.nokia.com/latest/qdeclarativemodels.html#qobjectlist-based-model

    ListView {
    width: 100; height: 100
    anchors.fill: parent

     model: myModel
     delegate: Rectangle {
         height: 25
         width: 100
         color: model.modelData.color
         Text { text: name }
     }
    

    }

    I tried to access to an element of the list with the get method:

    model.get(0).color

    as explained in many tutorials, but I received an error

    I tried also with model.get(0).modelData.color, but it is the same.

    How can I access that element?


Log in to reply
 

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