Proxy models - mapping a table model to a tree model

  • 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

Log in to reply

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