Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Getting model in delegate with custom QAbstractListModel and QML Repeater
Forum Updated to NodeBB v4.3 + New Features

Getting model in delegate with custom QAbstractListModel and QML Repeater

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.8k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    portoist
    wrote on last edited by
    #1

    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!:-)

    1 Reply Last reply
    0
    • P Offline
      P Offline
      portoist
      wrote on last edited by
      #2

      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?

      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