Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Accessing QAbstractItemModel data / roles outside ListView delegate
ludde last edited by
A ListView delegate can easily access the data of the current item in a model that is a QAbstractItemModel subclass using the role name.
But is it possible to access model data outside the delegate (without making it explicitly available as properties of the delegate)?
kahon last edited by
The way that I thought was:
//do that you want to each element controlling by index
I hope it is usefull for you.
mbrasser last edited by
There isn't any built-in way to access the data -- the typical workaround is to add slots (or Q_INVOKABLEs) to your model that can be called from QML to access this data. If you are only interested in the data from a single delegate, you could also consider "pushing" that information to a property higher up in the context chain (e.g. push the value to a property of the ListView when the delegate is clicked on).