I would like to concatenate multiple models into one tree view. When an index is selected in this treeview, I would like to be able to know what 'sub'model was selected and what index of that 'sub'model was selected.
# example data
Model1
data1
child 1
child 2
Model2:
data2
child 1
child 2
Treeview:
data 1
child 1
child 2
data 2
child 1
child 2
# example data
Model1
data1
child 1
child 2
Model2:
data2
child 1
child 2
Treeview:
data 1
child 1
child 2
data 2
child 1
child 2
To copy to clipboard, switch view to plain text mode
Purpose: If I clicked on child 2 of data 2, I would like to be able to call setModel(Model2) and setRootIndex(???) on a QTableView which I have set up as an editor.
If I implement a proxy view, what modifications do I need to make? See below:
data(): how do I know which model was clicked?
index(): how do I know which model to use?
parent(): ?
mapToSource(): ?
mapFromSource(): ?
rowCount(): sum of rowCount from all models
columnCount(): 1
QSortFilterProxy or QAbstractProxyModel?
data(): how do I know which model was clicked?
index(): how do I know which model to use?
parent(): ?
mapToSource(): ?
mapFromSource(): ?
rowCount(): sum of rowCount from all models
columnCount(): 1
To copy to clipboard, switch view to plain text mode
I'm thinking the key is in mapToSource/mapFromSource and having to count what row your on. Eg: If Model 1 has 10 rows and you are on row 12, and Model 2 as 10 rows, then you are requesting row 2 from model 2. Is this how it's done or is there a more elegant approach?
TYVM,
BB
Bookmarks