I have a model
that contains several QStandardItemModels
. Now I want to create a view that displays a TableView
for each QStandardItemModel
.
I had the idea to have a ListView
that has a TableView
as delegate, something like this:
ListView {
id: myListView
anchors {
fill: parent
margins: 5
}
model: testModel
delegate: CompareDelegate { }
}
And in CompareDelegate.qml
:
Item {
id: base
width: 500
height: 300
TableView {
anchors.fill: parent
}
}
How do I get the TableView
inside the delegate to use the appropriate QStandardItemModel
within the model of the ListView
?
I hope the question is somewhat clear.
Thanks in advance.
Interesting use case... I am still not sure if it's a good idea and am wondering if there's a better way to do it, but I couldn't think of reasons why it's bad, so I tried it out of curiosity:
main.cpp
main.qml
This works, but... it crashes on exit. :)
I've been unable to reproduce it while debugging with Creator, so I've only been able to get a stack trace manually on the command line with
gdb
, which I'm not too familiar with (have always used debuggers in IDEs :)). The crash is in QML's guts somewhere, while accessing some property. However, I've spent too much time on this to not post the answer, and I think it is still useful. Maybe some kind soul will find the problem and edit my post. :)