Getting model in delegate with custom QAbstractListModel and QML Repeater



  • Hello,
    I have implemented QAbstractListModel and made my model visible into QML by qmlRegisterType. In QML I have delegate component and I display model data with Repeater component. Now in delegate I need to call some model method (slot), I know that ListView has attached property ListView.view.model which provides you model instance in delegate. But repeater doesn't has such thing. So I have tried to add ModelRole to my QAbstractListModel implementation and have something like this in its data method:
    @ if (role == ModelRole) return QVariant::fromValue<MyModel*>(this);@
    But this doesl not build:-)
    I would like to know if I am able to get a model from Repeater somehow? Is it possible to provide pointer to model instance from data method, and how should I make it so that it would build and work?:-) Or do I have to use ListView? And if so, how can I set ListView to not flick an stay fixed as Repeater does?
    Thanks for your answers!:-)



  • So I found out that I can disable flicking on ListView with interactive property. But still is it possible to provide instance of model class via its data method?


Log in to reply
 

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