Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Proxy models - mapping a table model to a tree model
Forum Updated to NodeBB v4.3 + New Features

Proxy models - mapping a table model to a tree model

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 2.2k 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.
  • F Offline
    F Offline
    Fuwex
    wrote on last edited by
    #1

    Hi,

    I'm working on implementing a TableView in QML, and my approach is to dynamically wrap a Repeater element within each row of a ListView like so:

    @ListView {
    model: VisualDataModel {
    id: rowModel
    model: myModel
    delegate: Row {
    Repeater {
    model: mymodel
    rootIndex: rowModel.modelIndex(index)
    }
    }
    }
    }@

    (That's not my actual code, I only included the bare essentials for illustrating my approach)

    Using a custom model, essentially a Tree Model where each top-level item corresponds to a row of cells, it works like a simple tableview. However, I would like to have a proxy model between a regular table model and my QML component, to make using the component a breeze. After spending a day of trying various approaches, I cannot seem to be able to make it work with a proxy model approach (subclassing QAbstractProxyModel or QSortFilterProxyModel).

    I'm currently working on a custom QAbstractItemModel subclass which acts as a proxy transformer as a replacement, but I'm wondering if anyone can tell me if it's actually accomplishable using QAbstractProxyModel? Using mapFromSource() and mapToSource() alone, I can't seem to be able to create the hierarchy I need (seeing as the top-level items in the model required for the QML component are dummy parents which don't have equivalents in the table model). Is it possible?

    • Andreas
    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