Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Why model data isn't exposed as properties of the delegate object?

$
0
0
For a project menu I have a list view and a sidebar that display properties of selected project. I need to be able to access properties of delegate from the sidebar element. For the moment my workaround is to explicitly expose some functions in the delegate to have getters and setters. But I am expecting to be able to get a direct acess to model data from outside the delegate (“projectsListView.currentItem.name”) instead of using proxy functions (“projectsListView.currentItem.getName()”). Sample : GridView {  id: projectsListView    delegate: Component {   id: projectsDelegate     Item {    id: projectWrapper      // Workaround because modelData isn't accessible outside the delegate    function setName(text) {name = text;}    function getName() {return name;}      Item {     width: projectsListView.cellWidth     height: projectsListView.cellHeight     x: -parent.x     y: -parent.y       ProjectsMenuDelegate {      id: projectsMenuDelegate      width: projectsListView.cellWidth      height: projectsListView.cellHeight      x: parent.parent.x      y: parent.parent.y    }   }  }    model: projectsModel; }   TextField {  text: {return projectsListView.currentItem.getName();} } Maybe there is a better way to manage that? PS : My model is a c++ object that inherit from QAbstractListModel

Viewing all articles
Browse latest Browse all 4972

Trending Articles