PDA

View Full Version : display child rows of qstandarditemmodel in a table view



qsurvae
2nd July 2015, 04:46
I have a QStandardItemModel tree layout similar to this



1 ,col,col,col
1,col,col,col
21,col,col,col
77,col,col,col

4 ,col,col,col
4,col,col,col
89,col,col,col
3,col,col,col

7 ,col,col,col
7,col,col,col
.....




I can display the root rows only in a QTableView (ie:1,4,7), and the entire tree in a tree view, but the tree view lacks the functionality of the table view, ie: I need to be able to navigate between the cells and edit items using key shortcuts which works well with the QTableView focusNextChild().

I want to display the children of the root rows in a table view in groups one below the other, so that I can manipulate them directly through the table.

Alternatively: The main issue is that I cannot get a valid pointer to the parent row of the child row, ie: some cell in row 89 is in focus, I need a pointer to the parent row (row 4) so that I can access all of the children of the parent in a loop (ie: 4, 89, & 3). But I think it would be far more simple if I can manipulate them directly through the table.

Added after 1 40 minutes:

Looks like I can use QTableView::setRootIndex to change the group occupying the table. This should work.