-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Description
Hello @oKcerG!
What will be your best bet for usage SortFilterProxyModel
with TableView
directly (since SortFilterProxyModel
is subclass of QAbstractItemModel
)?
Expecting to have something like:
import QtQuick 2.14
import QtQuick.Window 2.14
import SortFilterProxyModel 0.1
Window {
visible: true
width: 640
height: 480
title: qsTr("SortFilterProxyModel and TableView")
ListModel {
id: fruitModel
ListElement { name: "Banana"; cost: 5 }
ListElement { name: "Apple"; cost: 9 }
ListElement { name: "Orange"; cost: 3 }
}
SortFilterProxyModel {
id: sfpm
sourceModel: fruitModel
}
TableView {
anchors.fill: parent
columnSpacing: 1
rowSpacing: 1
clip: true
model: sfpm
delegate: Rectangle {
implicitWidth: 100
implicitHeight: 50
Text {
text: display // "name" or "cost"
}
}
}
}
If I override QQmlSortFilterProxyModel::data
I can see it is executed only for indices:
QModelIndex(0,0,...)
QModelIndex(1,0,...)
QModelIndex(2,0,...)
with a different roles numbers (e.g.1
forcost
,0
forname
). But never ask for second column (e.g. indexQModelIndex(0,1,...)
) even if I overridecolumnCount
to return hardcoded value2
.
Can you help me to deal with it? Or can you point on the methods that I need to override to make it work properly?
Thanks in advance.
GTeufl and frostasm
Metadata
Metadata
Assignees
Labels
No labels